LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   need to correct work (https://www.linuxquestions.org/questions/linux-newbie-8/need-to-correct-work-4175491235/)

albana 01-14-2014 08:51 AM

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

TB0ne 01-14-2014 09:00 AM

Quote:

Originally Posted by albana (Post 5097772)
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.

TenTenths 01-14-2014 09:07 AM

Duplicate of http://www.linuxquestions.org/questi...nd-4175491130/

albana 01-14-2014 09:19 AM

Quote:

Originally Posted by TB0ne (Post 5097778)
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

albana 01-14-2014 09:20 AM

Quote:

Originally Posted by TenTenths (Post 5097783)

same person too...can you help me?

TB0ne 01-14-2014 09:37 AM

Quote:

Originally Posted by albana (Post 5097797)
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.


All times are GMT -5. The time now is 08:43 PM.