Shell command for the normal program termination of Skype from the command line 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:

pkill skype


It's better because:


It's shorter and cleaner
It won't kill itself


By the second point I mean that ps -e | grep skype will match the grep process itself too. That won't happen when using pkill.

Code review

If we wanted to imitate pkill, I would suggest writing like this:

ps -e | awk '/[s]kype/ { print $1 }' | xargs kill


That is:


Replace two processes with one (grep + cut with awk)
Use [s]kype instead of skype is a common trick to make the awk itself not match
Drop -s term from kill, as TERM is the default signal anyway