Viewing the differences between two directories on Linux servers
This past week I needed to compare the contents of two directories to see if there were any differences. There are a TON of ways to do this, though my preferred way is to use diff with the “-r” (when comparing directories do so recursively) option to compare two folders:
$ find foo1
foo1
foo1/services2
foo1/services
$ find foo2
foo2
foo2/services
$ diff -r foo1 foo2
Only in foo1: services2
Simple, easy and it gives you the output you’re most likely after. Anyone found a simpler solution that this? :)








Jbb on May 21st, 2011
Rsync -vn dir1 dir2
Add another v for an ls like output.
Has the advantages of being one command and works across servers using host1:dir1 host2:dir2