How to find differences between two directories using diff command

When you copy a directory with many files, you may want to check whether the copied directory is indeed an exact copy of the original. You can do that by comparing all files. You can write your own script checking every single file. You can also use standard tools under linux such as the diff command:

diff -r folder folder2 | grep -v "^diff -r " | sort

Here, the diff command check for all files recursively (-r). It returns a so-called diff file format including the differences. If we are interested by which files are different only, then we can use the grep command to simply return the file names that differ.

Please follow and like us:
error
This entry was posted in Linux and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published.