djeikyb
djeikyb

Reputation: 4588

Why does hexdump-ing multiple files output differently than hexdumping each file individually?

What is the difference between these commands? Why does the first match, but grepping the individual file hexdumps returns nothing?

$ hexdump -C DRAFT* FAIL* RCV* | grep "49 d0 38 ec 06 a1 c3"
0001f430  49 d0 38 ec 06 a1 c3 7a  10 39 9c 07 bd cd 66 10  |I.8....z.9....f.|
$ hexdump -C RCV* | grep "49 d0 38 ec 06 a1 c3"
$ hexdump -C DRAFT* | grep "49 d0 38 ec 06 a1 c3"
$ hexdump -C FAIL* | grep "49 d0 38 ec 06 a1 c3"
$ ls
DRAFT  DRAFT.HDR  DRAFTUSED  FAILED  FAILED.HDR  FAILEDUSED  RCVD  RCVD.HDR  RCVDUSED  SENT  SENT.HDR  SENTUSED  SMS.html

The files are from my Samsung Sync SGH-A707. I'm trying to parse these sms files so I can make a plain-text backup of my text messages. The string I'm grepping for is a control message I encoded according to http://www.dreamfabric.com/sms/hello.html

Upvotes: 0

Views: 966

Answers (1)

qbert220
qbert220

Reputation: 11556

Hexdump will concatenate the files, then convert to hex. If the character sequence is split across a line boundary, then it will not match your grep. I suspect this happens in some cases, but not others.

You could try using the -n option with a large number (larger than the files you are using) to put the whole output on a single line.

Upvotes: 1

Related Questions