Need help to kill pids

Hi there !!!
I am writing a script to kill the pids on different linux boxes :cool:

the output of my command gives the pids running on that box, but how can I kill all the pids without looping? :confused:

Code:
ssh $i ps -fu $USER | grep ManServer | grep -v grep | awk '{print $2}' | kill

error: :eek:
Usage: kill [-l] [-n signum] [-s signame] job ...
Or: kill [ options ] -l [arg ...]

I tried to dump the output to a file and able to kill the pids using for loop, but looking for one-line code :b:

ssh $i ps -fu $USER | grep ManServer | grep -v grep | awk '{print $2}' | (how_can_i_kill_here) :wall:

Thanks for the help :slight_smile:

have a good day

First of all you can easily get pids with pgrep command which does the same thing like your code and you can even use pkill which kills running processes by their names on similar basis. You just have to be very cautious about what pattern you are killing processes with.

Second thing is that you can even use loops within one line simply by separating different lines with semi-colons.

try using

| xargs kill 

instead of

| kill

@smoofy - pgrep works well but only on some UNIX OSes, not all. The OP did not specify which OS. Some OSes have pkill.

Thanks folks for the replies

I would look at the suggestions ...

by the way I am working on linux boxes

=> uname -a
Linux box_name 2.6.18-308.13.1.el5 #1 SMP Thu Jul 26 05:45:09 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux

and was able to locate
man pages for pkill ...
will post the results soon. Thanks