Unix-递归比较两个目录,将差异输出为列表减去目录 [英] Unix - Compare two directories recursively, output differences as a list minus directories

查看:89
本文介绍了Unix-递归比较两个目录,将差异输出为列表减去目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存档系统,可以将任何文件(以及该文件所在的相应目录结构)存档到另一个卷。它会忽略空目录。

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)

我的问题是,归档系统忽略的所有空目录都会显示并阻塞结果列表。是否有一个标志(或rsync的替代方法)可以仅列出两个目录之间的文件,而完全忽略目录中的差异。

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.

推荐答案

您可以使用 rsync -ai dir1 / dir2 / --dry-run 创建dir1和dir1之间的机器可读更改列表目录2。您必须自己过滤掉目录,但是语法很容易处理。

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.

这篇关于Unix-递归比较两个目录,将差异输出为列表减去目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆