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

后端 未结 2 1930
借酒劲吻你
借酒劲吻你 2021-01-31 08:29

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 a

2条回答
  •  礼貌的吻别
    2021-01-31 09:14

    Well i found the answer myself. I had tried it before, but I thought it did not work.

    diff -srq dir1/ dir2/ | grep identical
    

    What -srq means? From 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.
    

提交回复
热议问题