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 Answers1

2

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
steeldriver
  • 81,074
  • 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. –  Sep 06 '18 at 18:32