Powerful raw data viewing with “od”

I remember a few years ago using a command line tool called hexcat, which gave a great view into raw file data when you were suspicious of stray bytes or just curious as to exactly what a file contained. It turned out that this wasn’t bundled in standard distributions and, for one reason or another, I never got round to finding a substitute.

Recently, by chance, I came across the exact thing – “od” (think “octal dump”, because that’s it’s default output format). You can do a lot of cool things with this tool. Output hex and char stacked…

$ echo 'Hello World!' | od -t c -t x1
0000000   H   e   l   l   o       W   o   r   l   d   !  \n
         48  65  6c  6c  6f  20  57  6f  72  6c  64  21  0a
0000015

or get a 4 byte random unsigned int 🙂 …

$ dd if=/dev/urandom count=4 bs=1 2>/dev/null | od -A none -t u4
 3412455254