I need to kill all processs in a certain shell excluding certain processes.
Like sh which is my shell. And the comand.
This is what currently in my shell right now.
rcihp146 :/home/msingh2> ps
PID TTY TIME COMMAND
8880 pts/258 0:00 ps
5908 pts/258 0:00 sh
But if there are some extra processes I would like to kill all of them excluding the above two.
I tried a one liner for this purpose and it didn't work:
rcihp146 :/home/msingh2> ps | awk '{system("kill -9 $1")}'
sh: kill: The number of parameters specified is not correct.
sh: kill: The number of parameters specified is not correct.
sh: kill: The number of parameters specified is not correct.
sh: kill: The number of parameters specified is not correct.
But it works if I only give a specific pid like below:
rcihp146 :/home/msingh2> ps | awk '{system("kill -9 23456")}'
I need to exclude two or three process (like ps, sh) from being killed.
Is there any way to do this?
