On a full or desktop Solaris 11 installation, there are three
awk implementations available, plus some variants:
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
/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/bin/gawk is the GNU variant of
awk. It aims to comply with most or all of the POSIX standard when the environment variable
POSIXLY_CORRECT is set in the environment or when called with the
-W posix option but otherwise adds numerous specific own extensions.
pgawk are themselves extensions to
gawk, the first one supports include files and the second one supports profiling.
See also the GNU
awk history chapter for a lot of useful information.
core-os packages are guaranteed to be present on a Solaris 11 regular installation, thus only
nawk are there. In particular, when you create a new non global zone, it contains by default the
solaris-small-server group package so neither the
xpg4 nor the
awk binaries are available. This is by design. The
solaris-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 installed on the global zone was installed on the non global one too so 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 the
xcu4 package and set you PATH to the POSIX conformant one:
pkg install xcu4
Should for some reason you don't want to install that package, a workaround is to use a "custom"
mkdir -p /opt/posix/bin
cp /usr/bin/nawk /opt/posix/bin/awk
Alternatively, you might install
GNU awk and set your
PATH to get it first:
pkg install gawk
Note that this is not specific to Solaris 11. A similar package grouping was already existing under Solaris 10 and earlier and the POSIX compliant utilities were only installed in the "End User", "Developer" and "Full install" metaclusters. Having a system or a zone installed with the "Core" or "Networking support" metacluster would then have lead to the very same
xpg4 missing issue.
Note also that the lack of
/usr/xpg4/bin/awk in a Solaris 11 system is not a POSIX compliance failure. Only full Solaris installations are used in the vast majority of tests performed by Oracle and ISVs, including the Open Group certification program. Reduced installations are supported but not qualified.
Should you distribute shell scripts (or applications embedding shell scripts/calling shell commands) for Solaris 11, you just need to define
/system/xopen/xcu4 as a dependency in their IPS package and the installer will automatically do what is required for the script to work properly:
depend fmri=pkg:/system/xopen/xcu4 type=require