linuxstringcommand-linehexprintf

Convert string to hexadecimal on command line


I'm trying to convert "Hello" to 48 65 6c 6c 6f in hexadecimal as efficiently as possible using the command line.

I've tried looking at printf and google, but I can't get anywhere.

Any help greatly appreciated.

Many thanks in advance,


Solution

  • echo -n "Hello" | od -A n -t x1
    

    Explanation:

    Further details on ExplainShell.com: https://explainshell.com/explain?cmd=echo+-n+%22Hello%22+%7C+od+-A+n+-t+x1