MHR wrote: > #!/bin/bash > > # A shell script to kill that annoying runaway seamonkey that won't die > > case `basename $0` in > "seakill") cmd=seamonkey;; > "foxkill") cmd=firefox;; > *) echo "Unrecognized command."; exit 1;; > esac > > kill -9 `ps -ef | grep $cmd | grep -v grep | tail -1 | awk '{print $2}'` > ps -ef | grep $cmd | grep -v grep > > If it works, nothing is displayed. If seamonkey/firefox is already > gone, it give me kill's error for not finding the process (or for a > missing process number because 'ps' couldn't find it, either). > Isn't that command line a bit complex? Why not use ps options to get what you want rather than using grep, tail, and awk to pull the PID out of the standard output? ps -C $cmd -o pid= | xargs kill -9 ps -fC $cmd -- Bowie