差异文件存在于两个不同的目录中 [英] Diff files present in two different directories
本文介绍了差异文件存在于两个不同的目录中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个目录具有相同的文件列表。我需要使用 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/
这将输出忽略空格的递归diff,并带有统一上下文:
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
这篇关于差异文件存在于两个不同的目录中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文