www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/12/05:50:30

From: G DOT DegliEsposti AT ads DOT it
To: djgpp <djgpp AT delorie DOT com>
Message-ID: <C125658A.0039C38A.00@vega.ads.it>
Date: Mon, 12 Jan 1998 11:48:24 +0100
Subject: Re: DJGPP gawk peculiarity
Mime-Version: 1.0




>>One of my coworkers showed me a peculiar behavior of the DJGPP awk:
>>C:\TEMP> cat junk
>>123 456
>
>>C:\> awk 'length($1) < 2 {print $1}' junk
>>123
>>What am I missing here?
>
>The basics of awk ;-))
>awk 'runs' through the stdin executing between {}, in your case {print
>$1}, which prints the first field of every record.
>You placed 'length($1)<2'  before {} which becomes a search condition.
>What you probably mean is { print length($1) }

Well, it depends... if he wanted to print the first field of every line
then
*you* are right, but if he wanted to write it only for lines where first
field
is only 1 char, then *he* was right! :-)

ciao
  Giacomo



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019