[NTLUG:Discuss] kill command
Rick Renshaw
bofh69 at yahoo.com
Sun Jun 14 19:00:54 CDT 2009
----- Original Message ----
From: Ralph Green <sfreader at sbcglobal.net>
To: NTLUG Discussion List <discuss at ntlug.org>
Sent: Saturday, June 13, 2009 2:30:21 AM
Subject: [NTLUG:Discuss] kill command
Howdy,
I tried the following command and it does not quite work, and I don't
see why. Any suggestions?
ps -A -o pid -o cmd | grep "update-notifier" | cut -c1-5 | kill
If I do it without that last bit, I get the pid of the process I want
to kill. How do I need to change this to kill that process? I know it
will also get the pid of the grep command and kill that process, but I
can't see that that would hurt anything.
Good day,
Ralph
In general if you have a list being piped from one command to another and you want a command to be executed with the list as the argument, use xargs:
ps -A -o pid -o cmd | grep "update-notifier" | cut -c1-5 | xargs kill
In this particular case, killall is a better choice.
More information about the Discuss
mailing list