Forethinker
Forethinker

Reputation: 3758

A file save via notepadd++ is failing diff comparison on terminal

I saved a text file both in UTF-8 and ASCII using notepad++ on windows. The text, which had the same letter representation as the UNIX version, were claimed to be completely different by diff (e.g. 1,267c1,267). The files were actually different on binary level (xxd -b test.txt), but then vimdiff had different result than vim: it showed them to be identical. I am guessing because vimdiff renders the text before doing diff on files? Why is there such inconsistency?

Upvotes: 0

Views: 146

Answers (2)

Barton Chittenden
Barton Chittenden

Reputation: 4416

If you use the -b option to diff, it will ignore leading and trailing whitespace, including differences in end-of-line characters. If this doesn't take care of the problem, you can do a closer inspection of the individual files with hd (hexdump) or od -c (Octal dump, showing ascii characters).

Upvotes: 1

nab
nab

Reputation: 4861

Check end-of-line characters in the files you compare. It might be that you've saved them with \r\n at the end of each line while the Unix versions were terminated with \n.

Upvotes: 0

Related Questions