Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have two directories which are different versions of the same software package. I'd like to list all the files/directories that have changed between the two then copy those differences to a new directory.

I've been trying different scripts with md5sum and diff -Nurq but haven't been able to get the result I'm looking for.

Any recommendations?

share|improve this question
What does it mean to "copy a difference"? – cjm May 17 '11 at 18:35
I don't understand what you're trying to do. diff -r (or variations) gives you the differences already. What are you trying to do with them? – Gilles May 17 '11 at 20:20
up vote 7 down vote accepted

You should use rsync instead. Something like rsync -rv $old/ $new/ should do the trick: this will print the files it's going to copy over.

Run with additional -n for a dry-run before actually modifying the new directory.

share|improve this answer
That's brilliant. Thanks! – Rich May 17 '11 at 19:49
+1 for teaching me about 'dry run' mode! – SMTF Jan 20 '13 at 5:58

The best tool that I have found is using vim with the DirDiff plugin. If you use vim and vimdiff, this Plugin will be easy to learn.

The author describes it this way:


This is a utility that performs a recursive diff on two directories and generate a diff "window". Based on that window you can perform various diff operations such as opening two files in Vim's diff mode, copy the file or directory recursively to the other, or remove the directory tree from the source directory.

DirDiff is like using vimdiff to compare two directories, and all subdirectories and files contained therein. I use this tool often for comparing different Subversion branches, configuration directories on different hosts, etc.

For a screenshot, look at dedm's blog: http://dedm.livejournal.com/115224.html

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.