I need to print the ASCII value of the given character in awk only.
Below code gives 0 as output:
0
echo a | awk \'{ printf(\"%d \\n\",$1)
It seems this is not a trivial problem. I found this approach using a lookup array, which should work for A-Z at least:
BEGIN { convert="ABCDEFGHIJKLMNOPQRSTUVWXYZ" } { num=index(convert,substr($0,2,1))+64; print num }