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: 
```
xxd -p file

```

Or if you want it all on a single line:

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

```
I think this is the most widely supported version (requiring only POSIX defined `tr` and `od` behavior):

```
cat "$file" | od -v -t x1 -A n | tr -d ' \n'

```

This uses `od` to print each byte as hex without address without skipping repeated bytes and `tr` to delete all spaces and linefeeds in the output. Note that not even the trailing linefeed is emitted here. (The `cat` is intentional to allow multicore processing where `cat` can wait for filesystem while `od` is still processing previously read part. Single core users may want replace that with `< "$file" od ...` to save starting one additional process.)