From owner-freebsd-hackers Thu Mar 6 13:13:05 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id NAA11972 for hackers-outgoing; Thu, 6 Mar 1997 13:13:05 -0800 (PST) Received: from awfulhak.demon.co.uk (awfulhak.demon.co.uk [158.152.17.1]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id NAA11960 for ; Thu, 6 Mar 1997 13:12:57 -0800 (PST) Received: from awfulhak.demon.co.uk (localhost.lan.awfulhak.org [127.0.0.1]) by awfulhak.demon.co.uk (8.8.5/8.8.5) with ESMTP id UAA18855; Thu, 6 Mar 1997 20:47:44 GMT Message-Id: <199703062047.UAA18855@awfulhak.demon.co.uk> X-Mailer: exmh version 1.6.9 8/22/96 To: John Utz cc: hackers@FreeBSD.ORG Subject: Re: awk bug? in 2.2 BETA? In-reply-to: Your message of "Thu, 06 Mar 1997 10:23:34 PST." Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Thu, 06 Mar 1997 20:47:44 +0000 From: Brian Somers Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > 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 , Don't _EVER_ lose your sense of humour....