Diff 文件存在于两个不同的目录中 [英] Diff files present in two different directories
本文介绍了Diff 文件存在于两个不同的目录中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个具有相同文件列表的目录.我需要使用 diff
命令比较两个目录中存在的所有文件.是否有一个简单的命令行选项可以做到这一点,或者我是否必须编写一个 shell 脚本来获取文件列表,然后遍历它们?
I have two directories with the same list of files. I need to compare all the files present in both the directories using the diff
command. Is there a simple command line option to do it, or do I have to write a shell script to get the file listing and then iterate through them?
推荐答案
您可以使用 diff
命令:
diff -bur folder1/ folder2/
这将输出一个忽略空格的递归差异,具有统一的上下文:
This will output a recursive diff that ignore spaces, with a unified context:
- b 标志表示忽略空格
- u 标志表示统一上下文(前后 3 行)
- r 标志表示递归
- b flag means ignoring whitespace
- u flag means a unified context (3 lines before and after)
- r flag means recursive
这篇关于Diff 文件存在于两个不同的目录中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文