May 25, 2009
Don’t grep grep!!!
Well well, a linux user / admin who has a little respect for himself has to know that tool: grep.
Used for string searching, we can use it on the output of a command using the pipe character.
But, what happened when you do: ps x | grep firefox??
And yes, grep will grep himself:
$ ps x | grep firefox
8902 ? SNLl 59:29 /usr/lib/mozilla-firefox/firefox
9426 pts/9 SN+ 0:00 grep --colour=auto firefox
How could we fix this little cutie issue. We could use a sed… Yeah … or a head maybe… not that great either.
Or, we could hack grep!
Instead of using ps x | grep firefox, try ps x | grep [f]firefox!
Tell Me More!
Advertisement