Making sense out of byte-order in text I have stumbled about the way a text file is saved by the OS.
I have typed:

printf "ab" | hexdump


and the output was:


  6261


which are the letters in reversed order. My first intent was endianess, but this cannot be true, since at this level, such abstractions must be transparent to the programmer and user. Also endian would be:

$$ab  \mapsto 6162  \mapsto 2616$$

So I wondered, why would someone save a file like that?

Greetings,
Niclas
I'm not sure this is the right place for this question. Anyway, hexdump is interpreting your input as a 16-bit little-endian number, therefore the bytes 0x61 and 0x62 (which leave the pipe in the "correct" order) appear reversed. Try printf "ab" | hexdump -C .

00000000  61 62                                             |ab|
00000002