Heal Your Church WebSite

Teaching, rebuking, correcting & training in righteous web design.

What’s the diff … ?

diff [options] from-file to-file


In the simplest case, diff compares the contents of the two files from-file and to-file. A file name of – stands for text read from the standard input. As a special case, diff – - compares a copy of standard input to itself.

Here is an essential utility from the *nix world for those of you ‘shooting your foot clean-off‘ developing data-driven, dynamically-generated web content for your church or charity.

As the above definition from the ‘man‘ page describes, diff is a utility that compares to text files. Below is a sample session that shows how diff might be used in combination with wget in a real-World situation:

wget “http://www.csszengarden.com/?cssfile=/001/001.css&page=0” -O test001.html
wget “http://www.csszengarden.com/?cssfile=/002/002.css&page=0” -O test002.html
diff test001.html test002.html > whatsthediff.txt

Here’s a snippet of the output I piped into ‘whatsthediff.txt:’

< @import “/001/001.css”;

> @import “/002/002.css”;

There are a variety of options which can be used to customize the output so the results aren’t as cryptic, but generally the plain vanilla output works fine for me. ‘diff’ is also yet another compelling reason to install the UnxUtils on any Windows-based system on which you develop software.

For those of you who prefer a more ‘GUI-fried‘ interface, Keith Devens has compiled a rather short but sweet list of ‘Differencing Programs‘ including a nice little freebie by the name of “ComponentSoftware Diff for Windows” or “CDiff” for short. Another solution is Microsoft SDK Windiff utility.

Whatever your preference, a differencing program can be a big help when comparing the output from dynamically-generated web pages … or when you need to compare last night’s programming effort against last week’s.


  1. When I’m forced to use a Windows box, I use cygwin. It gives you the freedom to install all kinds of unix tools and have a shell too!


  2. If you’re using Windows, I highly recommend Beyond Compare. It’s not free, but if you do a lot of code comparison, it’s definitely worth the price.

    On Linux in KDE, I’ve started using KDiff3. So far, I haven’t needed to do a diff of three different versions of a file yet, but just knowing that I can fills me with joy…

  3. For those using Mac OS X, there’s a very nice diff/merge tool called FileMerge included on the Developer Tools CD. If you already have it installed, it’s at /Developer/Applications/Utilities/FileMerge.

  4. I second the kudos for Beyond Compare. It’s not free, and it’s overkill for basic comparison, but you can make it do just about anything.

  5. Watch out folks, Dean will have us all patching and compiling our Linux kernels with info like this!

    In all seriousness, though, diff is a great tool. I use it frequently to compare large text file data dumps to see incremental changes.

  6. Just one more thing…
    This isn’t really an alternative to diff, but if you want to compare versions of files, I highly recommend that you use CVS. Then you can get just about any CVS tool out there and do a compare between the files. Eclipse (http://www.eclipse.org) is a great IDE for this, and CVSDude (http://www.cvsdude.org) is a place where you can get a free CVS account.

  7. You can diff three files from the command line with `diff3′.

    Also, it’s a crime to not use the `-u’ option with diff; said option will make your diffs far prettier.