I was searching for how to do a reverse hexdump and found xxd mentioned. However, it does not seem to work with simply:
xxd -r hexdumpfile > binaryfile
I then compared the difference between outputs of xxd infile
and hexdump infile
, and found three differences:
- xxd output has a colon after the address
- xxd output has the positions in the data reversed (for example,
5a42
in hexdump output becomes425a
in xxd output) - There are some extra characters after each line
I only have the hexdumped version of certain files on a server. How can I correctly get back the binary data using xxd?
Best Answer
There's no one command that I know of that will do the conversion, but it can easily be broken up into a few steps:
hexdump
output usingsed
xxd
5a42
becomes425a
) usingdd
Here's the full command: