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.

  • 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, 2013 at 15:42

2 Answers 2


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
  • 1
    @firebush you can also use od -c to see all characters in the file (including \n and \r).
    – terdon
    Mar 3, 2013 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. Mar 3, 2013 at 15:36

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

diff file1 file2 | cat -t

This method also works simply with various version control tools

bzr diff | cat -t
  • In my case, this method is simpler, shorter, more readable. There is only one different, non-printable, character between two otherwise identical ASCII files. The accepted answer's output is longer, harder to grasp where the difference occurs. Jul 28, 2018 at 7:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .