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
Click on the “Select Files or Folders” tab in the far left, to start a new comparison. Each comparison you run opens in a new tab. To start a new comparison, click on the “Select Files or Folders” tab in the far left, change the targets and click “Compare” again.
Use the dircmp command to compare two directories specified by the Directory1 and Directory2 parameters and write information about their contents to standard output. First, the dircmp command compares the file names in each directory.
Normally diff reports subdirectories common to both directories without comparing subdirectories' files, but if you use the -r or --recursive option, it compares every corresponding pair of files in the directory trees, as many levels deep as they go.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With