diff showing too many 'diff'erences...

04th Jun, 2009 | unix

I like diff. If I'm developing the same codebase in more than one place and not using subversion or similar it's essential to have a command that can spot any differences quickly and easily.

Recently I was doing just this but getting way too many file differences, and most were xml files. I hadn't altered any xml files!

Turns out it was something to do with whitespace. Maybe the file encoding or linefeeds altered during ftp or something. Either way the -w option sorted it. Delving into the man pages revealed a few useful options:

-w : Ignore whitespace

-a : treat all as text

-d : look for minimal differences

-r : recursive

-q : quiet, only output if files differ

-x filename : exclude filenames (useful to ignore .DSStore, .svn, etc)