#!/bin/sh # Kill # Kill - ... # if [ $# -lt 1 ];then echo Usage: $0 -signal pattern;exit 1;fi if [ $# -lt 2 ];then S='-TERM'; else S="$1";shift;fi for p do P=`ps -wax \ | egrep "$p" \ | sed -e "/ $$ /d" -e "/ grep /d" -e 's/ */ /g' \ | /usr/bin/cut -f5` if [ -n "$P" ];then echo kill $S $P exec kill $S $P fi done exit 0 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # This script runs 'ps -wax' and kills the processes that match the pattern. # # Warning: It is very easy to kill more than you intended to kill. Note that # # on some Unix systems, the "kill" command doesn't accept symbolic names for # # signals; if yours is like this, then change the default '-TERM' to '-15'. # # The - arg may only be omitted when there's just a single pattern, # # because if there are two or more args, the first is assumed to be a signal. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # For BSD, you'll have to change "-wax" to "gawwux" or some such. # The Kill.sys5 version, which uses -elf, will also work on linux.