awk script

Jonathan I. Kamens jik at athena.mit.edu
Wed Mar 20 10:44:22 AEST 1991


In article <1991Mar19.171332.28055 at colorado.edu>, lewis at tramp.Colorado.EDU (LEWIS WILLIAM M JR) writes:
|> WRONG! WRONG! WRONG! See page 10 of the nawk book or Section 2.2 (page 3) of
|> the original Aho, Kernighan and Weinberger paper.  The default action is
|> to print $0.

  I am quite aware of the default action.  But that wasn't what I was
referring to.  You should read a little bit more carefully before you tell
someone that he is "WRONG! WRONG! WRONG!"

  The poster to which I was responding had this awk code:

	awk '{ $1 == ${ME} && $8 != "grep"  $2 }' `

Now, as I said in my last posting in this thread, that is not valid because he
has simply specified a field and expected awk to print it.  This is different
from the "default action" of printing $0, because the default action only
takes place when there is no '{ ... }' for awk to evaluate.

  Don't believe me?  Well, this (trivial example) doesn't work for me:

	ls -l | awk '{$2}'

and this does:

	ls -l | awk '{print $2}'

-- 
Jonathan Kamens			              USnail:
MIT Project Athena				11 Ashford Terrace
jik at Athena.MIT.EDU				Allston, MA  02134
Office: 617-253-8085			      Home: 617-782-0710



More information about the Comp.unix.questions mailing list