2

I have a function in bash to kill all the processes, which contain the same name:

killn () { pkill -9 -f $1; }

I realize that tcsh does not support functions.

How I can translate this function into an alias that will work in tcsh?

0

1 Answer 1

2

First, a warning to anyone who stumbles upon this post: the -f flag to pkill will cause it to match the pattern you give it with the full command line of each process rather than just the process's name. This matches more processes, so you may end up killing more than you intend. Be careful!

Since the pattern you are passing to pkill appears at the end of the command, you don't actually need explicit argument handling, so this can be done with the simple kind of tcsh alias:

alias killn pkill -9 -f

With that alias defined, if you want to send SIGKILL to processes whose full command lines contain a match to pattern, you use the alias like this:

killn pattern

That substitutes pkill -9 -f for killn, causing your desired command to be run:

pkill -9 -f pattern

Note to casual readers: this is a tcsh alias, which does not have the same syntax as a bash alias.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .