Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 06 Mar 1997 20:47:44 +0000
From:      Brian Somers <brian@awfulhak.demon.co.uk>
To:        John Utz <spaz@u.washington.edu>
Cc:        hackers@FreeBSD.ORG
Subject:   Re: awk bug? in 2.2 BETA? 
Message-ID:  <199703062047.UAA18855@awfulhak.demon.co.uk>
In-Reply-To: Your message of "Thu, 06 Mar 1997 10:23:34 PST." <Pine.OSF.3.95.970306101744.11587E-100000@becker1.u.washington.edu> 

next in thread | previous in thread | raw e-mail | index | archive | help
> Hello;
> 
> 	could an awk literate person comment on this ? The behavior on the
> follwing line of code appears to be awk version related. a linux guy
> running 3.0 patch 0 gets a correct answer, my freebsd 2.2 BETA awk 2.15p5
> does not.
> 
> mira: {60} cat fd1.dat | awk 'BEGIN { FS = " " }; END { printf "rf= %g; cf
> = %g\n;", NR, NF }'
> 
> rf= 9801; cf = 0;
> 
> cf should be 3!

Not really.  NF is the number of fields on the current line.  There's no
current line in END.

Try:

awk -F' ' '{nf=NF;} END{ print "rf= " NR ",cf= " nf; }'

if that's really what you want.  I'd consider the Linux 3.0pl0 as
having a bug if it thinks NR should be set in END ;|
-- 
Brian <brian@awfulhak.demon.co.uk>, <brian@freebsd.org>
      <http://www.awfulhak.demon.co.uk/>;
Don't _EVER_ lose your sense of humour....





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199703062047.UAA18855>