I always wonder how to do a diff on two directories. Then I find it out some way and am really happy to use it. But that’s it. I don’t write it down. So it’s the same next time – how do I diff two directories? This time I’m having enough of it. I’m *writing it down*. Here’s how to do it.
If you have two directories called OLDVERSION and NEWVERSION then use following command to get the differences between the old and the new tree.
diff -r -uN OLDVERSION NEWVERSION > old2new.diff
You’ll get a file with the differences as lines of unified context with absent files treated as empty. This file can now be used to patch an old version to the new version. Do it as follows:
patch -p0 < old2new.diff
VoilÃ . That's it.