LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Hexdump: inaccurate output? (https://www.linuxquestions.org/questions/linux-newbie-8/hexdump-inaccurate-output-803398/)

mattseanbachman 04-21-2010 06:08 PM

Hexdump: inaccurate output?
 
This is simple enough to explain, simply look at the following and see if you notice anything fishy:

Code:

toor@toor:~/Desktop/test$ hexdump test
0000000 6464 740a 0a74                       
0000006
toor@toor:~/Desktop/test$ hexdump -C test
00000000  64 64 0a 74 74 0a                                |dd.tt.|
00000006

It's a simple text file, two "d" characters, a newline, and two "t" characters, and another line break. Why the heck would the first invocation of hexdump appear to place things like "ddt(newline)(newline)t"?

allend 04-21-2010 06:19 PM

In the first invocation, the input has been read as 16bit integer words. The first character read is in the most significant byte and the second character is in the least significant byte.
In the second invocation, the input has been read as 8bit characters, as you would expect.


All times are GMT -5. The time now is 03:58 PM.