I’m now doing it this way:
[root@~]# echo Aa|hexdump -v
0000000 6141 000a
0000003
[root@~]# echo -e "\x41\x41\x41\x41"
AAAA
But it’s not exactly behaving as I wanted,
the hex form of Aa should be 4161,but the output is 6141 000a,which seems not making sense.
and when performing hex to ascii,is there another utility so that I don’t need the prefix \x ?
The reason is because
hexdumpby default prints out 16-bit integers, not bytes. If your system has them,hd(orhexdump -C) orxxdwill provide less surprising outputs – if not,od -t x1is a POSIX-standard way to get byte-by-byte hex output. You can useod -t x1cto show both the byte hex values and the corresponding letters.If you have
xxd(which ships with vim), you can usexxd -rto convert back from hex (from the same formatxxdproduces). If you just have plain hex (just the ‘4161’, which is produced byxxd -p) you can usexxd -r -pto convert back.