问题
I have an archive system that archives any file (and the corresponding directory structure of where that file is located) to another volume. It ignores empty directories.
After the archive has created a copy to an external volume, I've been using the following command to list the differences to make sure that no file has been missed:
diff -qr dir1(original) dir2(archive)
My problem is that all of the empty directories that the archive system ignores show up and clog the resulting list. Is there a flag (or an alternative way with rsync) that can just list the files that are different between the two directories and ignore differences in directories altogether.
Just to clarify, I'm not actually looking for differences in the files themselves, I'm just trying to compare two directory trees to see that they both have all the same files.
回答1:
you can use rsync -ai dir1/ dir2/ --dry-run
to create a machine-readable list of changes between dir1 and dir2. you would have to filter out the directories yourself, but the syntax is quite easy to handle.
来源:https://stackoverflow.com/questions/42008329/unix-compare-two-directories-recursively-output-differences-as-a-list-minus-d