Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hexdump's ability to read binary data and format it appropriately so it can, for example, be piped to awk is very useful, but I regularly need to read files in which the binary data is of a different endian-ness from that native to the system. In particular, I need to read big-endian data on a little endian machine. My ideal solution would be "hexdump" with a switch to reverse the endian-ness, but such a switch doesn't seem to exist.

Are there any good "next-best" solutions to this problem?

share|improve this question
up vote 3 down vote accepted

Is there a utility like hexdump that will handle non-native endian-ness?

Yes, the utility is called Perl.

Well actually Data::HexDumper - though you could roll your own.

A string specifying how to format the data. It can be any of the following,
which you will notice have the same meanings as they do to perl's pack function:

C        - unsigned char
S        - unsigned 16-bit, native endianness
v or S<  - unsigned 16-bit, little-endian
n or S>  - unsigned 16-bit, big-endian
L        - unsigned 32-bit, native endianness
V or L<  - unsigned 32-bit, little-endian
N or L>  - unsigned 32-bit, big-endian
Q        - unsigned 64-bit, native endianness
Q<       - unsigned 64-bit, little-endian
Q>       - unsigned 64-bit, big-endian
share|improve this answer
I'm not really happy with relying on perl and having to do the (admittedly very limited) extra typing compared to hexdump, but have become convinced better options don't exist. – ehneilsen Jul 13 '11 at 14:38

At least for 16-bit words one can pipe it through dd conv=swab as in,

cat file.dat | dd conv=swab | od -t x2
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.