Search code examples
sedhexdump

To use a single command in converting from binary to ascii hex


I am converting binary data into hex and viewing this hex data in head from a continuous stream. I run the following where the conversion is from here

echo "ibase=2;obase=10000;$(echo `sed '1q;d' /Users/masi/Dropbox/123/r3.raw`)" \ 
                                                                               \ 
| bc                                                                           \
                                                                               \  
| head

and I get

(standard_in) 1: illegal character: H

so wrong datatype.

How can you do the conversion form binary to binary ascii by a single command efficietly?


Solution

  • I run the following code based on Wintermute's comment

    hexdump -e '/4 "%08x\n"' r3.raw 
    

    For instance, head r3.raw | hexdump -e '/4 "%08x\n" gives

    ffffffff
    555eea57
    ...