If you need to compare two directories to determine which files are in one directory, but not another, on a Unix, Linux, or Mac OS X system, you can use the
diff
command. E.g., suppose the directories
are named dir1 and dir2; they can be compared with diff dir1 dir2
$ diff dir1 dir2 Only in dir2: index.html Common subdirectories dir1/temp and dir2/temp Only in dir2: a.png Only in dir2: b.png Only in dir1: 123.png Only in dir1: 456.png
If you wish to see only the differences and not common directories and
subdirectories, you can use diff dir1 dir2 | grep "Only"
.
To perform the comparision recursively through the various subdirectories
within the two directories use diff --recursive dir1 dir2
.
Reference: