Would the following be the right way to do it in your opinion? Can you suggest a better alternative or, if not, is there something that can be done to make the existing version better?
ps -e | grep skype | cut -d" " -f1 | xargs kill -s term
As the comments have pointed out, there exist tools to match processes by name. This is roughly equivalent (better than) what you're trying to do:
It's better because:
By the second point I mean that Code reviewIf we wanted to imitate
That is:
|
|||
|
killall
to take care of this. – chicks Jul 19 at 22:21/usr/bin/pkill
is in the same procps package as/bin/ps
, but/usr/bin/killall
is in a separate psmisc package. Also, fun fact: on Solaris,killall
actually tries to kill everything that it possibly can, regardless of command-line parameters! For both reasons, I recommendpkill
overkillall
. – 200_success♦ Jul 19 at 22:30