#!/usr/local/bin/perl -w # # kil (C) 2000 Stuart Caie # kills all processes with the same (given) name # this is distributed under the terms of the GNU public license version 2 # use strict; if ($#ARGV < 0 or $#ARGV > 1) { print "usage: $0 [kill level] \n"; print "kills all instances of \n"; exit 1; } my $name = $ARGV[$#ARGV]; my @kill = ('kill', $#ARGV > 0 ? ($ARGV[0]) : ()); # assumes that 'ps -u ' will print a list of all processes owned # by you, starting with the PID (possibly with leading spaces) and ending # with the name of the program (possibly with trailing spaces) map { print join(' ', (@kill, "$1\n")); system (@kill, $1); } grep { /\b$name *$/ && /^ *(\d+)/ } `ps -u $<`;