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?
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?
First, a warning to anyone who stumbles upon this post: the
-f
flag topkill
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 oftcsh
alias:With that alias defined, if you want to send
SIGKILL
to processes whose full command lines contain a match topattern
, you use the alias like this:That substitutes
pkill -9 -f
forkilln
, causing your desired command to be run:Note to casual readers: this is a
tcsh
alias, which does not have the same syntax as abash
alias.