Convert binary data to hexadecimal in a shell script

后端 未结 8 1639
日久生厌
日久生厌 2020-12-13 05:59

I want to convert binary data to hexadecimal, just that, no fancy formatting and all. hexdump seems too clever, and it \"overformats\" for me. I want to take x

8条回答
  •  旧时难觅i
    2020-12-13 06:21

    Watch out!

    hexdump and xxd give the results in a different endianness!

    $ echo -n $'\x12\x34' | xxd -p
    1234
    $ echo -n $'\x12\x34' | hexdump -e '"%x"'
    3412
    

    Simply explained. Big-endian vs. little-endian :D

提交回复
热议问题