Path: utzoo!utgpu!watmath!att!tut.cis.ohio-state.edu!mailrus!uflorida!haven!adm!xadmx!ritter@cs.msstate.edu
From: ritter@cs.msstate.edu (Thomas H. Ritter)
Newsgroups: comp.unix.questions
Subject: Re: Killing with awk vs. cut
Message-ID: <20608@adm.BRL.MIL>
Date: 15 Aug 89 15:30:53 GMT
Sender: news@adm.BRL.MIL
Lines: 29

In a recent article:

> From: Tricia Gardenhire 
> Subject: Summarize: killing with awk and grep
> 
> more about how grep, and awk work now.  Any way, to summarize, the
> easiest way to do this was:
> 
> kill `ps -aux | fgrep -e -sleeper | egrep -v fgrep | awk '{print $2}'`
> 
> Most other ideas were similar, but were more involved shell scripts.

I agree that this is an easy and convient solution, but one thing struck
me as I read people's postings to your question. 

All the solutions I saw used awk to get the second column of the
ps listing. Why use such a general purpose tool for so simple
a task? SystemV provides the cut command. eg.

kill `ps -aux | fgrep -e -sleeper | egrep -v fgrep | cut -d" " -f5`

This solution uses a program that is considerably cheaper in
overhead than awk. (awk is an interpreted language)

I know that some 4.XBSD systems don't provide cut. 
But, I think if a nice tool is available use it. (portablilty aside)

Tom Ritter
ritter@cs.msstate.edu