Compare the world

26 07 2008

I quite often have to compare files that were originally edited on Linux or a Mac and then edited in Windows.  If you subsequently run this through the 'diff' command line tool it will think every line is different because many Windows editors change the line endings from the Unix native LF (\n) to Dos/Windows native CRLF (\r\n).

There is however a solution to this problem, if you use diff in the following way it will stop these problems from happening:

diff --strip-trailing-cr -ubB

--strip-trailing-cr - Ignores the difference between Unix and Windows line endings
-u - Unified diff format (In my opinion the most readable and pretty much standard now)
-b - Ignore space change, ignores the difference in whitespace
-B - Ignore blank lines, if line spacing in certain areas has been changed this won't be a factor in the diff


Bookmark Compare the world  at del.icio.us Digg Compare the world

Trackbacks


No Trackbacks

Comments

Display comments as (Linear | Threaded)
No comments

Add Comment


Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA