Unix - Compare two directories recursively, output differences as a list minus directories

只谈情不闲聊 提交于 2019-12-24 06:40:32

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!