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 Answer 1

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
2
  • Thanks, but why the 00006 and not 00004? Commented Aug 11, 2015 at 22:53
  • Answer updated to explain the 6. Commented Aug 11, 2015 at 22:54

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.