LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-14-2014, 08:51 AM   #1
albana
LQ Newbie
 
Registered: Jan 2014
Posts: 8

Rep: Reputation: Disabled
need to correct work


I have a problem:need to bild a bash script who shows the history of shell commands,analize them and delete all commands that aren't in /bin and show the new list.if in the first list there are no commands that are in /bin show appopriate message .

I have a solucion: for hist in $(history | grep -v "/bin" | awk '{print $1}'); do history -d ${hist}; done

can someone tell me if it's right and how to show an apopriate message? thank you
 
Old 01-14-2014, 09:00 AM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,635

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by albana View Post
I have a problem:need to bild a bash script who shows the history of shell commands,analize them and delete all commands that aren't in /bin and show the new list.if in the first list there are no commands that are in /bin show appopriate message .

I have a solucion: for hist in $(history | grep -v "/bin" | awk '{print $1}'); do history -d ${hist}; done

can someone tell me if it's right and how to show an apopriate message? thank you
Better than someone telling you, is you actually running it, and seeing if it does what you'd like. If you executed that on your system, you'd have had your answer in less time than it took you to post.

If you're new to shell scripting, there are many tutorials (see the link in my posting signature), which can help you with loops/conditions and printing messages.
 
Old 01-14-2014, 09:07 AM   #3
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Duplicate of http://www.linuxquestions.org/questi...nd-4175491130/
 
Old 01-14-2014, 09:19 AM   #4
albana
LQ Newbie
 
Registered: Jan 2014
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TB0ne View Post
Better than someone telling you, is you actually running it, and seeing if it does what you'd like. If you executed that on your system, you'd have had your answer in less time than it took you to post.

If you're new to shell scripting, there are many tutorials (see the link in my posting signature), which can help you with loops/conditions and printing messages.
oh you are a genius thank you!I have never thought about running it!I wrote all that to see if someone have a better solution or idea,you aren't abligated to help,better if you don't write nothing
 
Old 01-14-2014, 09:20 AM   #5
albana
LQ Newbie
 
Registered: Jan 2014
Posts: 8

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by TenTenths View Post
same person too...can you help me?
 
Old 01-14-2014, 09:37 AM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,635

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by albana View Post
oh you are a genius thank you!I have never thought about running it!I wrote all that to see if someone have a better solution or idea,you aren't abligated to help,better if you don't write nothing
And it would be better if you actually wrote something on your own...you haven't shown ANY effort, and the one command you did post here was written by someone else.

We are always happy to HELP, but we aren't going to do your homework for you. YOU have to show some effort of your own..post what YOU have written/tried and where you're stuck. And its against the LQ Rules to double post a question...stick with your other thread.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] E: Unable to correct dependencies and software center won't work (properly) in AVLnx kjell159 Debian 9 08-06-2013 04:35 PM
the root password is correct but it don't work!!!!!!! nadia_kh Linux - Newbie 9 07-19-2012 08:21 AM
slackware 12.0, udev rules for usb-dev works, but mounting does not work correct paalmarker Linux - General 5 03-30-2010 01:51 AM
correct installation of drivers, but X doesn't work zivs Linux - Newbie 3 06-26-2006 05:15 PM
Santa Cruz Sound Card does not work even though i have installed the correct drivers marco13185 Linux - Hardware 15 04-12-2005 12:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration