Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Printing these characters in the "Canonical" format gives the output that I expect, while the default format throws me off.

$ echo " " |hexdump                  # Reversed?  
0000000 0a20
0000002

$ echo -n " " |hexdump               # Ok, fair enough.
0000000 0020

$ echo  " " |hexdump -C              # Canonical
00000000  20 0a                      | .|
00000002

With a different string, such as "123" the output is even more confusing:

$ echo  "123" |hexdump
0000000 3231 0a33                    
0000004

The output here does not seem "reversed", but rather shuffled. Would anyone care to explain (briefly) what is going on here?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

The default format is 16-bit little-endian unsigned ints.

The manual page of hexdump explains the default format as well:

 -x  Two-byte hexadecimal display.  Display the input offset in hexadecimal, 
     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.
share|improve this answer
    
Perhaps not part of a brief answer, but do you know why that is the default format? I mean to ask, what is it convenient for? –  Ярослав Рахматуллин Dec 6 '12 at 3:58
    
It's left over from when Unix was invented on 16-bit minicomputers in the 70s. –  Nicole Hamilton Dec 6 '12 at 5:11
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.