How to diff

December 6, 2005 — Leave a comment

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.

No Comments

Be the first to start the conversation!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s