给定两个目录树,我怎么可以找出哪些文件有什么不同? [英] Given two directory trees, how can I find out which files differ?

查看:153
本文介绍了给定两个目录树,我怎么可以找出哪些文件有什么不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想找到两个目录树之间的差异,我通常只执行:

If I want find the differences between two directory trees, I usually just execute:

diff -r dir1/ dir2/

这正是输出的差异相应的文件之间什么。我感兴趣的是刚开相应的文件,其内容不同的列表。我认为,这将仅仅是传递一个命令行选项来差异的事,但我无法找到该名男子页上的任何东西。

This outputs exactly what the differences are between corresponding files. I'm interested in just getting a list of corresponding files whose content differs. I assumed that this would simply be a matter of passing a command line option to diff, but I couldn't find anything on the man page.

有什么建议?

推荐答案

您说的Linux,所以你的运气了(至少应该是可用的,不知道什么时候加入的话):

You said Linux, so you luck out (at least it should be available, not sure when it was added):

diff --brief -r dir1/ dir2/

应该做你所需要的。

Should do what you need.

如果您也想看看,可能无法在任一目录下存在文件之间的差异:

If you also want to see differences for files that may not exist in either directory:

diff --brief -Nr dir1/ dir2/

这篇关于给定两个目录树,我怎么可以找出哪些文件有什么不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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