Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!think.com!mintaka!bloom-beacon!eru!hagbard!sunic!mcsun!ukc!acorn!ixi!ixi!pd From: pd@x.co.uk (Paul Davey) Newsgroups: comp.unix.shell Subject: Re: Grepping for a process (was Re: Killing process w/o number (csh)) Message-ID: Date: 17 May 91 10:44:04 GMT References: <8720012@hpdmd48.boi.hp.com> Sender: paul@x.co.uk (Paul Davey) Organization: IXI Ltd. Lines: 66 In-Reply-To: alien@hpdmd48.boi.hp.com's message of 5 May 91 00:30:06 GMT In csh alias psg 'ps aux | sed -n -e "/sed -n -e /d\\ /\!$/p\\ /TIME COMMAND/p"' (change 'ps aux' to 'ps -ef' for sysV.) Converting to a ksh or sh function is left as an exercise for the reader ... To kill I use this script which I picked this up from the net some time back. #!/bin/sh # slay : kill processes by names # # Do our best to locate the PIDs to kill from the give # process names. # MYNAME=`basename $0` Ask=yes case $1 in "") echo "Usage: $MYNAME process_name ..." exit 1 ;; -n) Ask=no; shift ;; esac # change 'ps aux' to 'ps -ef' for sysV. PSAUX=`ps aux` for pname do line= PID= PID=`echo "$PSAUX" | grep -i $pname | awk '!/grep|'$MYNAME'/ {print $2}'` for pid in $PID do if [ $Ask = yes ] then line=`echo "$PSAUX" | awk '$2 == '$pid' {print}'` echo -n "Kill ($line)? " read reply case $reply in [Yy]*) kill -9 $pid ;; esac else kill -9 $pid fi done done -- Regards, pd@x.co.uk IXI Limited Paul Davey pd@ixi.uucp 62-74 Burleigh St. ...!uunet!ixi!pd Cambridge U.K. "These are interesting times" +44 223 462 131 CB1 1OJ USA: 1 800 XDESK 57