Diff and Merge using FileMerge

Oct 26, '01 03:10:43PM

Contributed by: joel

Apple ships an application FileMerge with the developer tools CD which is certainly of use to people, developers or not. You can even call it from the command line. To call it from the command line to diff (editor: compare two files showing the differences between them) two files, use:

/Developer/Applications/FileMerge.app/Contents/MacOS/FileMerge[space]
-left <file1> -right <file2>

(Enter the above as one line, replacing [space] with an actual space character). You can put it in a shell script by creating a file in your ~/bin directory with execute permissions containing:

#!/bin/sh
/Developer/Applications/FileMerge.app/Contents/MacOS/
FileMerge -left $1 -right $2

(everything from /Developer... through $2 should be entered on the same line). You can also use this program to merge from the command line by creating a shell script containing:

#!/bin/sh
/Developer/Applications/FileMerge.app/Contents/MacOS/FileMerge[space]
-left $2 -right $3 ancestor $1 - merge $4

(everything from /Developer... through $4 should be entered on the same line)

Comments (2)


Mac OS X Hints
http://hints.macworld.com/article.php?story=2001102615104319