linux - Convert string to hexadecimal on command line -
i'm trying convert "hello" 48 65 6c 6c 6f
in hexadecimal efficiently possible using command line.
i've tried looking @ printf
, google, can't anywhere.
any appreciated.
many in advance,
echo -n "hello" | od -a n -t x1
explanation:
- the
echo
program provide string next command. - the
-n
flag tells echo not generate new line @ end of "hello". - the
od
program "octal dump" program. (we provide flag tell dump in hexadecimal instead of octal.) - the
-a n
flag short--address-radix=n
, n being short "none". without part, command output ugly numerical address prefix on left side. useful large dumps, short string unnecessary. - the
-t x1
flag short--format=x1
, x being short "hexidecimal" , 1 meaning 1 byte.
Comments
Post a Comment