There are several tools to compare files for changes out there for Mac OS X. I’ll cover a few here. The first and most basic is diff. From the command line, it looks like this:
diff -u old_file new_file
Where of course old_file is the old suspected filename, and new_file is the new one. This will give you a quick glance at what is new. Each line of difference in the new file will be preceded by a plus (+) symbol, and each difference in the old one will be preceeded by a minus (-) Last saved timestamps will appear at the very top of the output.
A cool trick – if you use TextMate, you can pipe your diff output to it and take advantage of TextMate’s fancy-schmansy code coloring:
diff -u old_file new_file|mate
Shift + Control + Option switches Textmate to the Diff bundle, and Shift + Control + Command + D will give you access to the context menu for all of the diff commands. Great for you Lightning Ruby Ninja™ coders out there who insist on never letting the tips of your fingers leave your keyboards.
If you have the XCode Developer Tools installed, you get a second option installed: opendiff, laced with a GUI app called FileMerge:
opendiff old_file new_file
What is cool about this is that if you run opendiff from the command line, FileMerge takes over and shows you your differences with sexy Mac-ness, replete with an array of search and code merging commands at your disposal. That’s hot.
If you like BBEdit, and who doesn’t, you have bbdiff at your disposal too:
bbdiff old_file new_file
BBEdit has a file comparison and merging utility built in which does not suck at all.
Extra Coolness for Dreamweaver users: Select opendiff or bbdiff in your prefereces to compare files with their corresponding GUIs this way:
- Dreamweaver > Preferences > File Compare
- Click Browse
- Select bbdiff or opendiff from the file dialog, click OK, and enjoy.
Lusty. So there’s a few options for finding out what your colleague did to break your perfect code. Happy diff-ing!