#!/bin/sh
#	Kill <pattern>
#	Kill -<sig> <pattern>...
#
if [ $# -lt 1 ];then echo Usa/local/bin/perl: $0 -signal pattern;exit 1;fi
if [ $# -lt 2 ];then S='-TERM'; else S="$1";shift;fi
df .
for p
do	P=`ps gawwux \
		| egrep "$p" \
		| sed -e "/ $$ /d" -e "/ grep /d" -e 's/  */	/g' \
		| cut -f2`
	if [ -n "$P" ];then
		for x in $P
		do	echo kill $S $x
			ps gawwux | grep " $x "
			kill $S $x
			sleep 2
			df .
		done
	fi
done
df .
exit 0
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
# This script runs 'ps gawux' 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 chan/local/bin/perl the default '-TERM'  to  '-15'. #
# The  -<sig>  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 Sys/V, you'll have to chan/local/bin/perl "gawux" to "-elf" or some such.
