Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

To share a configuration file between two computers, I emailed the file to myself via my gmail account. When I loaded the conf on the second computer, the program had trouble reading every line. Suspecting a problem with newline characters (dos vs unix style), I opened the file up in gvim. I didn't see any ^M's in there as I suspected. A 'set list' didn't show anything strange - just the text of the file with every line terminated by '$' as I expected. It looks perfectly fine. A cat of the file looks just as I'd expect it to.

Out of desperation, I moved the file out of the way and manually retyped the contents of the file in a split vim session (it's only about 20 lines). I ran a gvim -d on the two files, and that showed no differences.

I ran the program that uses the config file, and sure enough, it was now able to read the newly typed file just fine.

I md5sum'd the two files, and they do have different sums. I ran a diff on the original file and the newly typed file and it shows that every single line of the files are different. But I can't see any difference in the output.

So, I'm curious: what tool can I use to see the differences between these two files? gvim -d shows no differences, and diff shows that they are all different, but the output looks identical.

If I could attach the two files, I would.

share|improve this question
    
You can use file on those two files, which tells you also some unusual line endlings. I would bet that diff -b (ignores changes in whitespaces) reports also that the files are identical. –  mpy Mar 3 '13 at 15:42

2 Answers 2

up vote 4 down vote accepted

Use od -c to dump each file as hex, then diff the results.

od -c file1 > file1.hex
od -c file2 > file2.hex
diff file1.hex file2.hex
share|improve this answer
1  
@firebush you can also use od -c to see all characters in the file (including \n and \r). –  terdon Mar 3 '13 at 7:51
    
@terdon Good suggestion to use -c instead of -x. That is more readable output. I've made the change to my answer. –  Nicole Hamilton Mar 3 '13 at 15:36

I think an easier way is just to pipe your diff output through cat -t

diff file1 file2 | cat -t
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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