grep -v grep
In Unix shell scripting, grep -v grep wastes yet another call to grep(1). Some Unix now ship with pgrep(1). If the script requires portability, deal with the vendor ps(1) options (BSD versus SysV), then use a regular expression that excludes grep(1) from matching itself: ps -axo pid,command | grep 'ss[h]'. Another option: first gather the results from ps(1), and loop over them in a while loop. This method avoids false positives on the username or other columns, if only searching the command:
ps -axo pid,command | while read pid command; do # deal with $pid and $command … done
Peruse this and other Unix shell scripting tips.
Technorati Tags: Unix