How to create a hex dump of file containing only the hex characters without spaces in bash?

David Raswik picture David Raswik · Apr 10, 2010 · Viewed 228.4k times · Source

How do I create an unmodified hex dump of a binary file in Linux using bash? The od and hexdump commands both insert spaces in the dump and this is not ideal.

Is there a way to simply write a long string with all the hex characters, minus spaces or newlines in the output?

Answer

mark4o picture mark4o · Apr 10, 2010
xxd -p file

Or if you want it all on a single line:

xxd -p file | tr -d '\n'