8

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?

Rich
  • 445

2 Answers2

8

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.

alex
  • 7,223
5

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:

description

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

Stefan Lasiewski
  • 19,754
  • 24
  • 70
  • 85