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 big-endian. Does this mean that my machine is big-endian, or that the writers of hexdump were liked the big-endian format?

share|improve this question
    
As mentioned below, the output you show above is little-endian. Translating hex back to ASCII, it reads of so <nul> <lf>. For characters or machines with word sizes not equal to 2 bytes, 2 byte word display doesn't make much sense anyways. –  jw013 Nov 15 '12 at 1:11
add comment

2 Answers 2

up vote 5 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
add comment

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
add comment

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.