Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Jan 2004 18:40:38 +1030
From:      "Rob" <listone@deathbeforedecaf.net>
To:        "David Fleck" <david.fleck@mchsi.com>
Cc:        FreeBSD Mailing List <freebsd-questions@freebsd.org>
Subject:   Re: awk vs. nawk [Was: stumped... .]
Message-ID:  <006d01c3de63$b9e29a30$a4b826cb@goo>
References:  <20040118030911.GA18161@tao.thought.org><20040117215110.R602@grond.sourballs.org><007d01c3dd7d$d0917530$a4b826cb@goo> <20040118074234.J602@grond.sourballs.org>

next in thread | previous in thread | raw e-mail | index | archive | help
David Fleck asked on Mon Jan 19, 2004:


> What does 'nawk' do that 'awk' doesn't?  I've got both binaries on my
> system, but the nawk manpage is just a link to awk(1).

I believe that awk is the GNU version while nawk is the (rewritten) Bell
Labs original:

  > awk --version
  GNU Awk 3.0.6
  Copyright (C) 1989, 1991-2000 Free Software Foundation.

  [...snip...]

  > nawk -V
  awk version 20020210

You can see the code for both of them under /usr/src/contrib:

  > ls -ld /usr/src/contrib/*awk
  drwxr-xr-x  6 root  wheel  1024 Jul 12  2003 /usr/src/contrib/awk
  drwxr-xr-x  2 root  wheel   512 Jul 12  2003 /usr/src/contrib/one-true-awk

My subjective opinion is that [g]awk has more features but nawk is more
'standard'.

<off-topic>

I got into the habit of using nawk on Solaris, because Solaris awk is very
basic and a bit flaky. On that platform, nawk supports extended regexes and
has many more functions; it is also more reliable and has better error
checking. I read somewhere that A, W & K never intended awk to be used for
programs of any size, and when they realised this was happening they gave it
a major rewrite - 'new awk' was the result.

The Solaris manpage says

     nawk is a new version of awk that provides capabilities
     unavailable in previous versions. This version will become
     the default version of awk in the next major release.

but they've been saying that for at least 5 major releases.

</off-topic>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?006d01c3de63$b9e29a30$a4b826cb>