You're looking at the POSIX 2008 SUSv4 (Single Unix Specification) documentation. A lot of software pre-dates this, gawk
included. I suspect the gawk
implementation is 2001 SUSv2, and has not been updated completely over time.
The Linux (glibc) printf(3)
man page alludes to this problem (see the description of %a
about half way through, sorry no anchors to link to):
a, A
(C99; not in SUSv2) For a conversion, the double argument is converted to hexadecimal notation (using the letters abcdef) in the style [-]0xh.hhhhp±; [...]
nawk
/mawk
/gawk
don't simply call the underlying libc's printf()
or sprintf()
verbatim, they more or less reimplement format string processing. For mawk
see the do_printf()
function for example. Perl also implements its own format processing, the sprintf
man page is more up front about the details.
Things which do support %a
/%A
are:
- glibc-2.1 and later (1997), it's required for C99 features
- coreutils-5.1(ish)
printf
(i.e. /usr/bin/printf
)
- bash's builtin
printf
, since bash-2.05 if libc has support
- perl's
sprintf
since perl-5.22.0
See the accepted answer here for some additional background: The format specifier %a for printf() in C