Have you ever used diff to compare two files in Linux? Yes, diff is a very powerful tool. But did you know that you can use it to compare two directories?
By using the -r option, you can traverse a directory tree and check the differences between files and directories. With the -q option, you can suppress the line-by-line comparison in files. For example,
diff -rq dirA dirB
list the files that exist in dirA and not dirB, and vice versa. It also lists the files that differ between dirA and dirB. To make the list more elegant, you can use grep and sort. For example,
diff -rq dirA dirB | grep -v -e ”DS_Store” -e ”Thumbs” | sort > diffs.txt
does the same thing as the last example but it also removes uninteresting files, sort the list and output it to a file called diffs.txt