3

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.

Example:

  • 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.

2
  • 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, 2012 at 19:38
  • @Thor, that is correct. Jul 27, 2012 at 19:44

1 Answer 1

3

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .