Search code examples
bashhex

Conversion hex string into ascii in bash command line


I have a lot of this kind of string and I want to find a command to convert it in ascii, I tried with echo -e and od, but it did not work.

0xA7.0x9B.0x46.0x8D.0x1E.0x52.0xA7.0x9B.0x7B.0x31.0xD2

Solution

  • This worked for me.

    $ echo -n 54657374696e672031203220330 | xxd -r -p
    Testing 1 2 3$
    

    echo -n prevents a newline from being added to the end

    -r tells it to convert hex to ascii as opposed to its normal mode of doing the opposite

    -p tells it to use a plain format.