Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 27 May 2000 12:16:30 -0400
From:      Peter Radcliffe <pir@pir.net>
To:        stable@FreeBSD.ORG
Subject:   Re: killall question
Message-ID:  <20000527121630.A18184@pir.net>
In-Reply-To: <20000527093625.A1557@nc.rr.com>; from aa8vb@nc.rr.com on Sat, May 27, 2000 at 09:36:25AM -0400
References:  <200005271258.IAA29766@thehousleys.net> <20000527093625.A1557@nc.rr.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Randall Hopper <aa8vb@nc.rr.com> probably said:
> Here's the shell script I settled on to override the default
> /usr/bin/killall:
> 
>      ps -x | grep "$1" | egrep -v "grep|$0" | awk '{print $1;}'

Ewwww.

Pet peeve #24; if you're piping grep to awk, you shouldn't be.
               if you're piping grep to grep to awk, you did too much crack
               this morning.

ps -x | awk '/'$0'/ { system("kill " $1) }'

When I want to kill something specific I usually check the owner of the
processes as well (it might not be mine, and I usually want to do this
as root.

ps -aux | awk '$1 == "owner" && $11 == "command" { system("kill " $2) }'

awk is quite a nice little language, and includes every feature of grep
you'd want to use.

P.

-- 
pir                  pir@pir.net                    pir@net.tufts.edu



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-stable" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000527121630.A18184>