Dumping a binary file with od(1)

I was recently working on an embedded device that provided a limited CLI interface and was looking for an utility to dump a binary file.

I was aware of hexdump(1) but alas, it was not available on my platform. That is how I discovered od(1).

The two commands are pretty similar, here is how I used od(1) to display serialized data (binary data with a bunch of text in it) over serial console:

od -Ax -tc /path/to/data
  • display addresses in hex
  • characters are displayed in the default character set and nonprinting are converted

Here is how the first few bytes of the od executable look like:

dd if=/usr/bin/od of=/dev/stdout count=10 bs=1 | od -Ax -tc  

0000000  177   E   L   F 002 001 001  \0  \0  \0                        
000000a