I don’t know why when I run diff program on my workstation. It gave output differences while the file contents seem to be the same for me.
Here is my output result
But when I use vimdiff to open the files. They show nothing difference. Anyone knows the reason?
PS. I used the command of diff a.txt b.txt and vimdiff a.txt b.txt
Thanks for answering
I don’t know why when I run diff program on my workstation. It gave
Share
I usually find it has to do with the line endings. DOS-style files with have line endings of
CR/LF(carriage return and line feed (a)) while UNIX-style files will just haveLF.While they may look the same, they’re not. I would suggest you do a hex dump of the files to see what actual (but hidden) characters are there, with something like:
A file with DOS-style line endings will have
\r \nat the end of each line. UNIX-stle will have just\n(b).(a) A throwback to typewriter days, when carriage return meant literally to slide the carriage to the left, and line feed meant to scroll the paper through one line, leaving the print head at the same position across the paper. Usually, these operations were combined but not always.
(b) Mac-style files, at least until they wised up and started using a decent OS under the hood, had just
\r, theCRcharacter.