If I want find the differences between two directory trees, I usually just execute:
diff -r dir1/ dir2/
This outputs exactly what the differences are between corresponding files. I'm interested in just getting a list of corresponding files whose content differs. I assumed that this would simply be a matter of passing a command line option to diff
, but I couldn't find anything on the man page.
Any suggestions?
You said Linux, so you luck out (at least it should be available, not sure when it was added):
Should do what you need.
If you also want to see differences for files that may not exist in either directory:
These two commands do basically the thing asked for:
The choice between them depends on the location of dir1 and dir2:
When the directories reside on two seperate drives, diff outperforms rsync. But when the two directories compared are on the same drive, rsync is faster. It's because diff puts an almost equal load on both directories in parallel, maximizing load on the two drives.
rsync calculates checksums in large chunks before actually comparing them. That groups the i/o operations in large chunks and leads to a more efficient processing when things take place on a single drive.
You can also use
Rsync
andfind
. Forfind
:But files with the same names and in the same subfolders, but with different content, will not be shown in the lists.
If you are a fan of GUI, you may check Meld that @Alexander mentioned. It works fine in both windows and linux.
I like to use
git diff --no-index dir1/ dir2/
, because it can show the differences in color (if you have that option set in your git config) and because it shows all of the differences in a long paged output using "less".Diffoscope is a great command line based directory diff tool.
I especially like about it that it can diff into files:
It will not only tell you which files differ, but also how they differ.
The find diff use this command:
-r will diff all subdirectories too -q tells diff to report only when files differ.
--brief will show the files that dosent exist in directory.
Or else
we can use Meld which will show in graphical window its easy to find the difference.