I'm trying to create a "changed files" package from one directory to another and need to find a Linux/Unix tool/utility that will be able to handle this.


  • Package_1.1/ (old)
  • Package_1.2/ (new)
  • changed_files/ (only changed and new files and directories)

changed_files would be a directory containing a recursive structure of only files that have been added or changed in Package_1.2 compared to Package_1.1)

Update: I tried using:

cd Package_1.2
rsync -a -c --compare-dest=../Package_1.1 . ../changed_files/
find -depth ../changed_files -type d -empty -delete

However there were some files that had a slightly different modified time that were copied over, yet the contents were identical. (md5 produced an identical checksum on each file). So while I think I'm close using this command, I'm still missing something.

  • To be clear, you want to copy files from Package_1.2 that are different from those in Package_1.1 into a new directory maintaining the same directory structure? – Thor Jul 27 '12 at 19:38
  • @Thor, that is correct. – Highway of Life Jul 27 '12 at 19:44

When using rsync, It seems that the -c (--checksum) option does not override the -t (--times) option within -a (--archive), which uses -rlptgoD, and thus it will still look at file modification times.

One possible solution is to use: -rlpgoDc rather than -a. The command would look like this:

cd Package_1.2
rsync -rlpgoDc --compare-dest=../Package_1.1 . ../changed_files/
find -depth ../changed_files -type d -empty -delete

This may not be the most elegant solution, perhaps someone has a better idea of how rsync can do the whole job by itself.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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