linux/solaris kill many proccess with one command

Solution 1:

This will work on both Linux and Solaris and do precisely what you need:

pgrep -f 'find /etc'     # verify the listing before proceeding
pkill -9 -f 'find /etc'

In your situation, avoid killall. If you use it on Linux, sooner or later you will mistake the ssh sessions, run it on Solaris, creating unnecessary risk.

The -f option of pgrep/pkill means to match the entire command line. In case you need to match path of the program or script (/var/tmp/test.sh), this works if you had run it with the entire path. To be precise, you only need to escape the . so you need

pkill -9 -f '/var/tmp/test\.sh'

If you have run the same program as ./test.sh you need to kill it as such. See -f option in ps.

Solution 2:

Use pkill find which is a variant of pgrep (process grep). On Linux, killall find would also work.