I want to compare two directories, one is local and the other is on another machine.
How can I do that? Can I do it with
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
I can think of two ways here..
Mount your remote directory locally, and then use diff as you would do on a local machine.
rsync -avz --dry-run remote-user@remote-machine:remote-dir local-dir
This will show you the files that differ, but will not show you the actual
diff. I think Unison supports diff also, but I have never used it and it does not seem to be under development any more.
If you just want to determine whether they're identical or not, something like
cd <directory> find . -type f | sort | xargs sha1sum | sha1sum
...should give you a single checksum over the entire contents (except empty subdirectories). So you can run this on both machines and compare the outputs.
Note that using
diff will require the entire contents of the remote directory to be transferred over the network, which could become prohibitively slow if there are large files or large numbers of files involved.
My recommendation would be to first determine which files differ between the two machines (by using
rsync -n --delete (
-n causes it to only tell you what it would do, but without actually doing it;
--delete will tell you if any files exist in the destination, but not in the source, because it will want to delete them) or by comparing
md5sums. If you're looking for how they're different (rather than just if they're different), I would then use
diff only on those specific files to see what the differences are.
Yes, you can do it with diff! User space applications such as "diff" don't know (and don't need to know) if a directory is local or remote.
I found a tool called " UNISON " . it is a very good tool and have many options .