diff and ignoring spaces and end of lines (unix, dos EOL)

Possibly you will need to either do a diff between files where they don’t use the same new line character.

Because the new line character is OS-dependant, there are issues when doing a diff on these files when you are not using that same OS.
And there are also times where you just want diff to ignore all spaces and new lines…

The –ignore-all-space option for diff is really useful in these two cases. It will check for differences between the given files ignoring spaces or new lines whether there is none, one or more

This option can be very useful for scripts or mark-up languages or to see if some newly indented code is similar to the old version. (For example it can be very useful for testing indenting tools).

Usage Example:

diff -u --ignore-all-space samplefile1.txt samplefile2.txt

For more details, type:

man diff

3 Replies to “diff and ignoring spaces and end of lines (unix, dos EOL)”

Leave a Reply