I saw this question Why does Ctrl-D (EOF) exit the shell? and wanted to try the example on the second answer. So i've created a file and used hexdump:

federico@home ~ $ cat > test.txt
federico@home ~ $ hexdump test.txt 
0000000 7270 766f 0a61                         

The second row has '6' in the end, and if i try to use http://www.rapidtables.com/convert/number/hex-to-ascii.htm to decode from hex to ascii i get a strange letters order. Why does this happen? Thanks


You are using a little endian CPU, the 16 bit words hexdump is showing are byte swapped.

6 is the offset of the second dump line which is empty, your file containing only six bytes.

Use od -c or od -t x1 to get the expected order:

$ od -c test.txt 
0000000   p   r   o   v   a  \n
$ od -t x1 test.txt 
0000000 70 72 6f 76 61 0a
  • Thanks, but why the 00006 and not 00004? Aug 11 '15 at 22:53
  • Answer updated to explain the 6.
    – jlliagre
    Aug 11 '15 at 22:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.