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.
|