Jump to content

(noobie) piping


Recommended Posts

why piping here? just use the output of your first command as a parameter for the second one:

 

~$ kill -9 $(ps -C mpg123 -o pid=)

 

or

 

~$ kill -9 $(/sbin/pidof mpg123)

 

 

but Steve Scrimpshire is right, the more stright forward way will be using /usr/bin/killall:

~$ killall -e -s SIGKILL mpg123

 

 

btw, usually SIGKILL (same as kill -9) is not a good idea since the process killed that way probably won't be able to close itself the right way. Is better to try to kill it with a signal 15 (SIGTERM), and if that doesn't work, then kill it with signal 9.

Link to comment
Share on other sites

Yes, killall is easier, and try without -9 first.

Also the $(ps ...) idea is good.

 

Anyway if you still want to do this with a pipe, this should work:

ps -C progname -o pid | xargs kill

or

ps -C progname -o pid | xargs kill -9

 

Yves.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...