On Mar 19, 2008, at 9:01 AM, Dustin J. Mitchell wrote:
On Wed, Mar 19, 2008 at 7:18 AM, J. Milgram <[EMAIL PROTECTED]> wrote:
:~: echo -n ab | hexdump -e "\"\" 2/2 \"%02x\" \"\n\""
6261
:~: echo -n ab | hexdump -e "\"\" 2/1 \"%02x\" \"\n\""
6162
I expected them to yield the same result. Why does the first example
reverse the bytes?
Because of the byte ordering on your system. Your system is
little-endian, which means it stores the least-significant bytes first
in memory.
See http://en.wikipedia.org/wiki/Little_endian
Dustin
--
Storage Software Engineer
http://www.zmanda.com
Another way of looking at it is that under 2/2 it's dumping 16 bit
"words", while under 2/1 it's dumping 8 bit bytes.
Dumping a 32 bit word:
echo -n abcd | hexdump -e "\"\" 1/4 \"%02x\" \"\n\""
64636261
Dumping two 16 bit words:
echo -n abcd | hexdump -e "\"\" 2/2 \"%02x\" \"\n\""
62616463
Dumping four 8 bit bytes:
echo -n abcd | hexdump -e "\"\" 4/1 \"%02x\" \"\n\""
61626364
-zben