I am new to unix and need some help here. I have two directories present on two different server. both the directories contains the same files. Now i want to check if all files are in sync in both the directories. If files are not in sync then i want to display only name of those files. I am able to do it when directories are on same server. not able to figure out how to do this when directories are present on two different servers.
eg:
server1 /abc/home/sample1/
server2 /abc/home/sample2/
here i want only files name to display when it not in sync.
Thanks in advance
On server1:
This is pretty fast but probably not as accurate as rsync since it uses file size instead of hash of content. Also, the rsync from kielni's answer will not show anything if server2 has more files then server1. Instead try this:
You can use rsync with the
-n
flag to find out if the files are in sync, without actually doing a sync.For example, from server1:
This will print the names of all files (recursive, with the
-r
flag) that differ betweenserver1:/abc/home/sample1/
andserver2:/abc/home/sample2/
In scenario of no connectivity between two servers, use "tree" command to get directory structure in files and then diff two files.