Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: kill and pid files



-----BEGIN PGP SIGNED MESSAGE-----

	Zoltan Hidvegi <hzoli@xxxxxxxxxxxxxxxxxxx> wrote in
	Message-ID: <199706190642.CAA05741@xxxxxxxxxx>
	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-----



Messages sorted by: Reverse Date, Date, Thread, Author