..

xxd 使用


字符串到16进制

$ echo -n "hello world" | xxd -g1
00000000: 68 65 6c 6c 6f 20 77 6f 72 6c 64                 hello world

十六进制到字符串

$ echo -e "\x68\x65\x6c\x6c\x6f\x20\x77\x6f\x72\x6c\x64"
hello world


[options]说明

-n     do not output the trailing newline
 -g          number of octets per group in normal output. Default 2 (-e: 4).
-e     enable interpretation of backslash escapes


参考

【1】man xxd
【2】man echo