March 2018
Beginner to intermediate
416 pages
9h 24m
English
This works with format control letters. For %o octal notation it adds a leading zero in the output. For %x and %X hexadecimal format control characters it adds a leading 0x or 0X, respectively for a nonzero result. For %e, %E, %f, and %F, the result always contains a decimal point. For %g and %G, trailing zeros are not removed from the result. The following example illustrates the workings of a hash (#) modifier:
$ vi printf_hash_modifier.awk BEGIN { printf "Octal representation = %#o\n", 10 printf "Hexadecimal representation = %#X\n", 10 printf "Trailing zeros in %% g = %#g\n", 10}$ awk -f printf_hash_modifier.awk
The output on execution of the preceding code is as follows:
Octal representation = 012Hexadecimal representation ...
Read now
Unlock full access