I have a situation where I have 2 large directory trees, an old and a new. Most files are the same, but some are different and/or missing in the old version. I would like to find a way to automatically create a tar file that contains:
a) all files in new that are not in old
b) all files that are different between new and old

Files that only exist in old should be ignored. Symbolic links need to be maintained. "Different" needs to be determined by a full binary comparison.
As you might guess, I'm trying to create a patch to get one tree to match another. Maybe there is already a tool to do this, or perhaps I need to string together some commands.
I'm am working in Ubuntu Linux.

  • Does it have to be a tarball? I'm thinking of rsync --read-batch... Commented May 23, 2019 at 5:03
  • It needs to be a tarball eventually, but creating a tree with the changed files could be a good intermediate stage.
    – Jon
    Commented May 23, 2019 at 6:00

1 Answer 1


I found some ideas on this post on how to get a list of the files that are different. I went with an rsync approach with the --dry-run option:

rsync -rv --dry-run --size-only --links old/ new/

Once I had the list of files, I invoked tar with those files. This didn't totally solve the issue of differentiating files only in 1 place vs. the other, but with some manual intervention, I got it to work. I wish I could have gotten to a fully automated solution, but I was able to solve my immediate problem with these general steps.

You must log in to answer this question.

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