Comparing directories in local or remote hosts
shell | rafacas | (0)
I frequently need to compare two directories (with similar structures) to find different or new files. When I have to compare them locally, I use the diff command.
$ ls test*
test:
file1 file2 file3 file4 file5
test.new:
file1 file2 file3 file4 file5 file6
$ diff -qr test test.new
Files test/file2 and test.new/file2 differ
Files test/file4 and test.new/file4 differ
Only in test.new: file6
The -q option tells diff to tell only whether the files differ and the -r option is for recursively comparing inside subdirectories.
A more complicated problem arises when the comparation has to be done remotely, that is one of the directories is in another host (Samba, NFS, etc ...