Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

On my machine I get the following output when I run these commands:

$ echo foos > myfile
$ hexdump myfile
6f66 736f 000a

The output from hexdump is little-endian. Does this mean that my machine is little-endian, or does hexdump always use little-endian format?

share|improve this question

2 Answers 2

up vote 6 down vote accepted

Yes, the traditional BSD hexdump utility always uses the platform's endianness. Use hexdump -C (or od -t x1) to get more sensible byte-by-byte output.

share|improve this answer

From the manpage:

 -x      Two-byte hexadecimal display.  Display the input offset in hexa‐
         decimal, followed by eight, space separated, four column, zero-
         filled, two-byte quantities of input data, in hexadecimal, per
         line.

...

 If no format strings are specified, the default display is equivalent to
 specifying the -x option.

Your output is actually little-endian (least significant byte first), which is also the endianness of the x86 and x86_64 architectures, which you are probably using.

share|improve this answer

Your Answer

 
discard

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.