I have a file containing a list of hexadecimal numbers, as 0x12345678
one per line.
I want to make a calculation on them. For this, I thought of using awk
. But if printing an hexadecimal number with awk
is easy with the printf
function, I haven't find a way to interpret the hexadecimal input other than as text (or 0
, conversion to integer stops on the x
).
awk '{ print $1; }' // 0x12345678
awk '{ printf("%x\n", $1)}' // 0
awk '{ printf("%x\n", $1+1)}' // 1 // DarkDust answer
awk '{ printf("%s: %x\n", $1, $1)}' // 0x12345678: 0
Is it possible to print, e.g. the value +1?
awk '{ printf(%x\n", ??????)}' // 0x12345679
Edit: One liners on other languages welcomed! (if reasonable length ;-) )