1

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
prova
^C
federico@home ~ $ hexdump test.txt 
0000000 7270 766f 0a61                         
0000006

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

1 Answers1

9

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
0000006
$ od -t x1 test.txt 
0000000 70 72 6f 76 61 0a
0000006
jlliagre
  • 61,204