From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5883 invoked from network); 21 Jun 1997 15:16:03 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 21 Jun 1997 15:16:03 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id LAA20399; Sat, 21 Jun 1997 11:09:29 -0400 (EDT) Resent-Date: Sat, 21 Jun 1997 11:04:06 -0400 (EDT) Message-Id: <199706211508.LAA08120@kira.peak.org> Content-Type: text/plain MIME-Version: 1.0 (NeXT Mail 4.1mach v148) In-Reply-To: <199706190642.CAA05741@hzoli.home> X-Nextstep-Mailer: Mail 4.1mach (Enhance 2.0b6) From: "Timothy J. Luoma" Date: Sat, 21 Jun 97 11:07:53 -0400 To: Zoltan Hidvegi Subject: Re: kill and pid files cc: rstone@accesscom.com, zsh-users@math.gatech.edu Reply-To: luomat@peak.org References: <199706190642.CAA05741@hzoli.home> Organization: Princeton Theological Seminary X-Url: http://www.peak.org/~luomat/ X-NeXTStep-Url: http://www.peak.org/~luomat/next X-PGP-Key: Email me Resent-Message-ID: <"aeLjS1.0.ay4.cr-gp"@euclid> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/909 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu -----BEGIN PGP SIGNED MESSAGE----- Zoltan Hidvegi wrote in Message-ID: <199706190642.CAA05741@hzoli.home> Date: Thu, 19 Jun 1997 > Oh, this is a really overcomplicated solution for a simple problem. How > about this: > > pid () { > local i > for i > do > ps acx | sed -n "s/ *\([0-9]*\) .* $i *\$/\1/p" > done > } Yes but what if there is more than one process by that name? I usually want to kill them all. This just kills one of them, whereas my solution kills them all (that's what the 'tr' part is for).... however, it may be "improvable": Here's my function again pid () { for i in $* do echo `/bin/ps -auxwww | grep -v grep | grep -w $i | awk '{print $2}' | tr -s '\012' ' '` done } it also takes multiple arguments, in case you need to kill several things at once TjL -----BEGIN PGP SIGNATURE----- Version: 2.6.2 iQCVAwUBM6vuTXTLzwEnIUsVAQH7GQP/RJCSAHfSE4kvkbd39ik9wlhnqEgw6vW6 eW9yrJesVN63mucnD8zjUqNu4KKmsA1AsN0o8s14zyn5f32iaH3bVUNRPI37DVlI 2x/mGqi7Rc4rrtNAKH2tu8wnmlsetq8nlJV828WQI+iJkE/vH4Bzidz8BkajMTAN L0FiUOIglss= =d8aX -----END PGP SIGNATURE-----