Friday, January 6, 2012

How to compare 2 directories using Unix diff command

Sometimes I am working on 2 different branches and want to compare them just to see how far off they are from each other. I found the unix diff command pretty handy for this

Following is the command
diff --recursive --exclude=.svn branch1 branch2

I have customized the output for my taste as
diff --minimal --recursive --exclude=.svn --exclude=log  branch1 branch2 \
| sed 's/diff --recursive /\n::::::::::::::::::::::::::::::\n: STARTING NEW FILE\n::::::::::::::::::::::::::::::\n&/g' \
| sed 's/Only in /\n::::::::::::::::::::::::::::::\n: STARTING NEW FILE\n::::::::::::::::::::::::::::::\n&/g'

The diff command is very powerful, here is full documentation
http://linux.about.com/library/cmd/blcmdl1_diff.htm

No comments:

Post a Comment