Quote:
Originally Posted by
Yoda
Don, are you suggesting OP to use xpg4/xpg6 awk instead of awk because this code will fail or you want OP to avoid using it because it is broken and not recommended?
The awk in /bin or /usr/bin on Solaris 10 is the awk that was present in 1977-1985 UNIX Systems. On most UNIX and UNIX-like systems, nawk replaced awk in 1985 or shortly thereafter. On UNIX System V Systems (and on Solaris/SunOS 5.1 and later systems) the old awk kept the name
awk and the new awk was named
nawk.
If you want an historical version of awk to run awk scripts from that era use the Solaris 10 default
awk. (On most other systems that have an
awk from this era, it is known as
oawk.) Otherwise, (including anytime your are writing new awk scripts to run on a Solaris 10 system) I believe you should use
nawk,
/usr/xpg4/bin/awk, or
/usr/xpg6/bin/awk to get a version of awk that conforms to the POSIX and UNIX Standards and includes the updates to awk that Aho, Weinberg, and Kernighan described in their 1988 book
The AWK Programming Language (ISBN 020107981X).
When writing new scripts, there is no reason to try to figure out if a script will be processed by the 1975 language interpreter in the same way that a current awk would interpret the script when we know that
nawk and
/usr/xpg[46]/bin/awk will reliably do what we all expect awk to do today.
PS. I am not suggesting that the default awk on Solaris systems is broken. I am suggesting that it is there to run historical awk scripts (which it does well). But, it should not be used when writing new awk scripts.