如何使用Shell脚本在两个不同目录中比较具有相同名称的文件 [英] How to compare files with same names in two different directories using a shell script
问题描述
在继续使用SVN之前,我曾经通过简单地保存 / develop /
目录并在其中编辑和测试文件,然后将其移动到 / main /
目录。当我决定迁移到SVN时,我需要确保目录确实是同步的。
Before moving on to use SVN, I used to manage my project by simply keeping a /develop/
directory and editing and testing files there, then moving them to the /main/
directory. When I decided to move to SVN, I needed to be sure that the directories were indeed in sync.
因此,编写shell脚本的好方法是什么[bash ]来递归地比较两个不同目录中具有相同名称的文件?
So, what is a good way to write a shell script [ bash ] to recursively compare files with the same name in two different directories?
注意:上面使用的目录名称仅用于示例。我不建议将代码存储在顶层:)。
Note: The directory names used above are for sample only. I do not recommend storing your code in the top level :).
推荐答案
diff命令具有-r选项以递归比较目录:
The diff command has a -r option to recursively compare directories:
diff -r /develop /main
这篇关于如何使用Shell脚本在两个不同目录中比较具有相同名称的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!