diff仅输出文件名 [英] diff to output only the file names

查看:393
本文介绍了diff仅输出文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个Linux命令,该命令将递归比较两个目录并仅输出不同的文件名.这包括一个目录中存在的所有内容,而不是另一目录中的所有内容,反之亦然,以及文本差异.

I'm looking to run a Linux command that will recursively compare two directories and output only the file names of what is different. This includes anything that is present in one directory and not the other or vice versa, and text differences.

推荐答案

在diff手册页中:

-q  仅报告文件是否不同,而不报告差异的详细信息.
-r  比较目录时,以递归方式比较找到的所有子目录.

-q   Report only whether the files differ, not the details of the differences.
-r   When comparing directories, recursively compare any subdirectories found.

示例命令:

diff -qr dir1 dir2

示例输出(取决于语言环境):

Example output (depends on locale):

$ ls dir1 dir2
dir1:
same-file  different  only-1

dir2:
same-file  different  only-2
$ diff -qr dir1 dir2
Files dir1/different and dir2/different differ
Only in dir1: only-1
Only in dir2: only-2

这篇关于diff仅输出文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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