Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!usc!cs.utexas.edu!ut-emx!walt.cc.utexas.edu!santhosh From: santhosh@walt.cc.utexas.edu (Santhosh S. Cheeniyil) Newsgroups: comp.unix.questions Subject: Re: Killing with awk and grep Summary: Script to kill processes by name using 'awk' and 'grep'. Keywords: kill, awk, grep Message-ID: <17073@ut-emx.UUCP> Date: 14 Aug 89 21:38:07 GMT References: <303@opus.NMSU.EDU> Sender: news@ut-emx.UUCP Reply-To: santhosh@walt.cc.utexas.edu (Santhosh S. Cheeniyil) Distribution: usa Organization: The University of Texas at Austin, Austin, Texas Lines: 27 In article <303@opus.NMSU.EDU> tgardenh@nmsu.edu (Tricia Gardenhire) writes: >Hi, I've been reading the man pages for awk, but they just aren't that >helpful. So here is my question: I want to create a shell script >that will look at ps -aux for a certain process called '-sleeper' and >then kill it. I've figured out how to search for it using grep and >how to display the PID with awk. But, I have no idea how to use these >with kill in mind. Something else I'm sure you will know, how do I >keep the script from killing itself? Grep will find everything with >the word '-sleeper' including the grep command finding the word. >Any ideas. Try the following: #/bin/csh kill -9 `ps | grep sleeper | grep -v grep | awk '{print $1}'` >-Tricia Cheers, --santhosh (Santhosh S. Cheeniyil) --santhosh (Santhosh S. Cheeniyil) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ If I don't drive around the park, I'm pretty sure to make my mark. If I'm in bed each night by ten, I may get back my looks again. If I abstain from fun and such,