given two directory trees how to find which files are the same?

来源:互联网 发布:医学大数据分析工资 编辑:程序博客网 时间:2024/05/17 02:43

I am writing a bash script, and I would like to know which files are the same in two directory trees.

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

You can use a utility like fdupes or rdfind to list duplicate files. For example:

fdupes --recurse dir1 dir2

You might also want to use the --sameline flag to list all duplicates on the same line, rather than in text blocks, depending on how you want to parse the results.

阅读全文
0 0
原创粉丝点击