Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!usc!apple!vsi1!wyse!bob
From: bob@wyse.wyse.com (Bob McGowen Wyse Technology Training)
Newsgroups: comp.unix.questions
Subject: Re: Killing with awk and grep
Message-ID: <2361@wyse.wyse.com>
Date: 14 Aug 89 23:52:36 GMT
References: <303@opus.NMSU.EDU> <4128@cps3xx.UUCP>
Sender: news@wyse.wyse.com
Reply-To: bob@wyse.UUCP (Bob McGowen Wyse Technology Training)
Distribution: usa
Organization: Wyse Technology
Lines: 24

In article <4128@cps3xx.UUCP> usenet@cps3xx.UUCP (Usenet file owner) writes:
>in article <303@opus.NMSU.EDU>, tgardenh@nmsu.edu (Tricia Gardenhire) says:
>> 
>> Hi, I've been reading the man pages for awk, but they just aren't that
---deleted description---
>ps -axe | grep pattern | grep -v grep | awk '{print "kill -9 " $1}' | sh
>
>
>Robert Raisch - TechnoJunkie & UnixNut| UseNet: {uunet,mailrus}!frith!raisch

Why not let awk do all the pattern processing:

ps -aux | awk '$10 ~ /^-sleeper$/{print "kill -9 " $2}' | sh

Using the -aux as in the original question puts the user name in the first
field, the PID in the second.  The tenth field is the first part of the
command, or command name.  The tilde tells awk that the 10th field must
match the pattern as given beginning to end (of the FIELD).  The awk line
is therefor excluded because on it the tenth field is: awk

Bob McGowan  (standard disclaimer, these are my own ...)
Customer Education, Wyse Technology, San Jose, CA
..!uunet!wyse!bob
bob@wyse.com