1

What I want to see:

$ printf "\U1F600\n"|hexdump -v -e '1/1 " %03o"'|tr ' ' '\\'
\360\237\230\200\012

What I tried:

$ printf "\U1F600\n"|hexdump -v -e '1/1 "\\%03o"'
hexdump: bad conversion character %�

$ printf "\U1F600\n"|hexdump -v -e '1/1 "\%03o"'
hexdump: bad conversion character %%

$ printf "\U1F600\n"|hexdump -v -e '1/1 "\\\%03o"'
hexdump: bad conversion character %\

$ printf "\U1F600\n"|hexdump -v -e '1/1 "\\\\%03o"'
\\\\360\\\\237\\\\230\\\\200\\\\12
1

Based on this example in the hexdump man page:

       # hex with preceding 'x'
       % echo hello | hexdump -v -e '"x" 1/1 "%02X" " "' ; echo
       x68 x65 x6C x6C x6F x0A

it seems you can use -e '"\\" 1/1 "%03o" '

Ex.

$ echo hello | hexdump -v -e '"\\" 1/1 "%03o" ' ; echo
\150\145\154\154\157\012
| improve this answer | |
  • Thanks! This is the right way. I didn't need the backslash in the format string itself (my bad ;) ), just in front of each output item. – user306023 Sep 6 '18 at 18:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy