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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...