"Strong Scripting Skills" - a definition? - sunday

Rob Windsor windsor at warthog.com
Mon Jan 26 19:03:28 PST 2004


On Mon, 26 Jan 2004 16:51:58 PST, verily did "Robert Hajime Lanning" write:

> <quote who="Rob Windsor">
>> I always thought "grep foo | grep -v grep | awk '{print $2}'" script
>> fragments existed only because the scripter didn't know how to write
>> "awk '/foo/ {print $2}'".

> Then again it would be:
> awk '/foo/ {if (!/awk/) {print $2}}'

> Things are not always as easy as they sound.  :)

Sure they are, until you think too much about it.  :-)

Your example would replace:
   grep foo | grep -v grep | grep -v awk | awk '{print $2}'

.. and not the original code fragment.


> This, of course, assumes (very badly) that you don't want to kill an awk
> process.

This is a good point, actually.  In the name of "safety checking", you've
introduced an assumption that may have broken the original intention.

We did not define the parameters under which this code fragment operates.

Rob++
----------------------------------------
Internet: windsor at warthog.com                             __o
Life: Rob at Carrollton.Texas.USA.Earth                    _`\<,_
                                                       (_)/ (_)
"They couldn't hit an elephant at this distance."
  -- Major General John Sedgwick



More information about the Baylisa mailing list