From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17530 invoked from network); 19 Jun 1997 12:35:22 -0000 Received: from euclid.skiles.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 19 Jun 1997 12:35:22 -0000 Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id IAA17529; Thu, 19 Jun 1997 08:19:38 -0400 (EDT) Resent-Date: Thu, 19 Jun 1997 08:15:36 -0400 (EDT) Date: Thu, 19 Jun 1997 05:19:36 -0700 (PDT) From: Matt Welland X-Sender: mwelland@pdx201 To: Users Zsh Subject: Re: kill and pid files In-Reply-To: <199706190642.CAA05741@hzoli.home> Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Resent-Message-ID: <"_b6I32.0.kC4.dBIgp"@euclid> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/908 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu On Linux the killall command does what I need (I am forever doing "killall diald" - but thats another story - *sigh*). However the little snippet below just went into my .zshrc - AIX killall doesn't take process names as parameters. See - if you watch this list long enough at least 80% of those little "argh - I must get around to writing that" bits of code will get written for you! --Matt On Thu, 19 Jun 1997, Zoltan Hidvegi wrote: > > well, I don't have the file part, but I use this > > > > pid () { > > > > for i in $* > > do > > echo `/bin/ps -auxwww | grep -v grep | > > grep -w $i | awk '{print $2}' | tr -s '\012' ' '` > > > > done > > > > } > > 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 > } > > Under Linux, you can even do that without ps or sed: > > pid2 () { > local i > for i in /proc/<->/stat > do > [[ "$(< $i)" = *\((${(j:|:)~@})\)* ]] && echo $i:h:t > done > } > > Zoltan >