Octal and Hexadecimal Constants in gawk

gawk allows you to use octal and hexadecimal constants in your program source code. The form is as in C: octal constants start with a leading 0, and hexadecimal constants with a leading 0x or 0X. The hexadecimal digits af may be in either uppercase or lowercase.

$ gawk 'BEGIN { print 042, 42, 0x42 }'
    34 42 66

Use the strtonum( ) function to convert octal or hexadecimal input data into numerical values.

Get Linux in a Nutshell, 6th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.