Is there a nice Unix command for dumping the text representation of a binary file? Is there a nice Unix command for dumping the text representation of a binary file? unix unix

Is there a nice Unix command for dumping the text representation of a binary file?


To solve this kind of problem using standard Unix tools, you typically pipe a bunch together:

od -v -t d4 ~/.profile | awk '{$1 = ""; print}' | fmt -1 | sed 's/^ *//'

The od prints every 32-bit word in decimal, with preceding offsets. The awk comment removes the offsets. The fmt command forces one integer per line. The sed command strips leading spaces off the result.


Try the following hexdump(1) incantation:

hexdump -v -e '4/4 "%d\t"' file

-v forces printout of the whole file (no * for repeating lines),
-e takes format string '4/4 "%d\t"' that tells hexdump(1) to iterate four times, printing four bytes at each iteration with given printf-like mask.


Doesn't od -An filename give you the data without the offset?