给定两个目录树如何找到相同的文件? [英] given two directory trees how to find which files are the same?
本文介绍了给定两个目录树如何找到相同的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在编写bash脚本,我想知道两个目录树中的哪些文件相同.
I am writing a bash script, and I would like to know which files are the same in two directory trees.
这与使用diff相反.
It would be the opposite of using diff.
好吧,我自己找到了答案.我以前曾经尝试过,但是我认为它不起作用.
Well i found the answer myself. I had tried it before, but I thought it did not work.
diff -srq dir1/ dir2/ | grep identical
推荐答案
好吧,我自己找到了答案.我以前曾经尝试过,但是我认为它不起作用.
Well i found the answer myself. I had tried it before, but I thought it did not work.
diff -srq dir1/ dir2/ | grep identical
-srq 是什么意思?来自 diff --help :
-s --report-identical-files Report when two files are the same.
-r --recursive Recursively compare any subdirectories found.
-q --brief Output only whether files differ.
这篇关于给定两个目录树如何找到相同的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文