问题
I am comparing two text files and I get the following result
diff file1 file2 | grep 12345678
> 12345678
< 12345678
As you can see the same string exists in both files, and both files were sorted with sort
.
The line endings must be getting in the way here (windows vs unix).
Is there a way to get diff
to ignore line endings on unix?
回答1:
Use the --strip-trailing-cr
option:
diff --strip-trailing-cr file1 file2
the option causes diff
to strip the trailing carriage return character before comparing the files.
来源:https://stackoverflow.com/questions/40974170/how-to-ignore-line-endings-when-comparing-files