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: 
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.)
tldr;
=====

```
$ od -t x1 -A n -v <empty.zip | tr -dc '[:xdigit:]' && echo 
504b0506000000000000000000000000000000000000
$

```

Explanation:
============

Use the `od` tool to print single hexadecimal bytes (`-t x1`) --- without address offsets (`-A n`) and without eliding repeated "groups" `(-v)` --- from `empty.zip`, which has been redirected to standard input. Pipe that to `tr` which deletes (`-d`) the complement (`-c`) of the hexadecimal character set (`'[:xdigit:]'`). You can optionally print a trailing newline (`echo`) as I've done here to separate the output from the next shell prompt.

References:
===========

* <https://pubs.opengroup.org/onlinepubs/9699919799/utilities/od.html>
* <https://pubs.opengroup.org/onlinepubs/9699919799/utilities/tr.html>