Killing with awk vs. cut
Thomas H. Ritter
ritter at cs.msstate.edu
Wed Aug 16 01:30:53 AEST 1989
In a recent article:
> From: Tricia Gardenhire <tgardenh at nmsu.edu>
> 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 at cs.msstate.edu
More information about the Comp.unix.questions
mailing list