Skip to main content
1 of 9
jlliagre
  • 62.5k
  • 11
  • 124
  • 162

On a full or desktop Solaris 11 install, there are three awk implementations available, plus some variants:

/usr/bin/awk pkg:/system/[email protected] /usr/bin/nawk pkg:/system/[email protected] /usr/bin/oawk pkg:/system/[email protected] /usr/gnu/bin/awk pkg:/text/[email protected] /usr/bin/gawk pkg:/text/[email protected] /usr/bin/igawk pkg:/text/[email protected] /usr/bin/pgawk pkg:/text/[email protected] /usr/xpg4/bin/awk pkg:/system/xopen/[email protected] 

They are all "standard compliant", albeit complying with different standards.

  • /usr/bin/awk is complying with the legacy UNIX awk implementation released in 1977. It is kept first in the default system PATH not to break existing scripts as subsequent awk releases break compatibility. oawk is a synonymous of the awk

  • /usr/bin/nawk is the "new" version of awk, first shipped in SVR3.1 in 1986. Awk POSIX standard was based on this implementation. /usr/xpg4/bin/awk is almost identical to the former, but the one that is formally checked against POSIX conformance validation tests.

  • /usr/gnu/bin/awk, also /usr/bin/gawk is the GNU variant of awk. It aims to comply with most or all of the POSIX standard but adds numerous specific own extensions. igawk and pgawk are themselves extensions to gawk, the first one supports include files and the second one supports profiling.

Only the core-os packages are guaranteed to be present on a Solaris 11 regular installation, thus only oawk/awk and nawk are there. In particular, when you create a new non global zone, it contains the small-server group package so neither the xpg4 nor the gnu awk binaries are available. This is by design. The small-server group is a minimal start point to which you add the required packages for your applications to properly work. This is more secure and efficient than the previous (Solaris 10) way where everything was installed and you had to remove unused packages when you wanted to minimize the zone.

To get POSIX awk support a portable way in such a small server installation, you need to install one of the xcu4 and set you PATH to the POSIX conformant one:

pkg install xcu4 PATH=$(getconf PATH):$PATH 

Should for some reason you don't want to install that package, a workaround is to use a "custom" PATH containing nawk as awk, e.g.:

mkdir -p /opt/posix/bin cp /usr/bin/nawk /opt/posix/bin/awk PATH=/opt/posix/bin:$PATH 

Alternatively, you might install GNU awk and set your PATH to get it first:

pkg install gawk PATH=/usr/gnu/bin:$PATH 
jlliagre
  • 62.5k
  • 11
  • 124
  • 162