Ascii/Hex convert in bash

前端 未结 15 1506
广开言路
广开言路 2020-12-12 21:03

I\'m now doing it this way:

[root@~]# echo Aa|hexdump -v
0000000 6141 000a                              
0000003
[root@~]# echo -e \"\\x41\\x41\\x41\\x41\"
A         


        
15条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-12 21:13

    echo append a carriage return at the end.

    Use

    echo -e
    

    to remove the extra 0x0A

    Also, hexdump does not work byte-per-byte as default. This is why it shows you bytes in a weird endianess and why it shows you an extra 0x00.

提交回复
热议问题