Get the grep Out!

by admin on October 24, 2007

While using grep to search for a running process from a ps ax output, it also includes the grep command, but in some cases (for example in a script) this is undesirable. To have a 'clean' output you can use brackets in this way for the grep command:

$ ps ax | grep s[s]h
4920 ?    Ss 0:00   /usr/sbin/sshd
$ 

This Tech Tip was brought to us by Alessandro in Italy. Thanks, Alessandro!

Instant fame is easy at Linux Journal. Just send us your useful Tech Tips to share with the Linux Community, and we'll send you a cool t-shirt for your efforts!

Please note: Tech Tips featured in this specific section of LinuxJournal.com are kindly brought to us by readers and are not necessarily tested by LinuxJournal.com editors.