Question: 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: 
Format strings can make hexdump behave exactly as you want it to (no whitespace at all, byte by byte):

```
hexdump -ve '1/1 "%.2x"'

```

`1/1` means "each format is applied once and takes one byte", and `"%.2x"` is the actual format string, like in printf. In this case: 2-character hexadecimal number, leading zeros if shorter.
It seems to depend on the details of the version of `od`. On OSX, use this:

```
od -t x1 -An file |tr -d '\n '

```

(That's print as type hex bytes, with no address. And whitespace deleted afterwards, of course.)