Linux Forums - Linux Help,Advice & support community:LinuxSolved.com

Network Troublshooting => Linux Servers Support => Topic started by: chuikingman on September 22, 2009, 04:25:31 AM

Title: compare/diff two directory in two different linux/unix machine
Post by: chuikingman on September 22, 2009, 04:25:31 AM
Hi,
  I have two server , one linux and one unix .
I want to compare two different directry in them .
What command or tool I can use instead of search the dir one by one ???

thank
Title: Re: compare/diff two directory in two different linux/unix machine
Post by: pedro on September 28, 2009, 09:19:17 AM
Have you checked rsync? Example:

$ rsync -avz --list-only /my/local/directory/ remore-server:/the/path/to/remote/dir/

This should list the files that are different in the local directory that would be copied to the remote if you'd run the rsync command without the --list-only option.

HTH.
Title: Re: compare/diff two directory in two different linux/unix machine
Post by: neko on October 19, 2009, 08:37:12 AM
I used the following command on Open SUSE to list files in the current directory that are different or do not reside on a remote server directory. This comparison does not look at the time stamps on the files and also skips files that are the same size.

rsync -nvr  --size-only ./ freddy@remotehost:/home/freddy/bin

The -n option is used to perform a test or (dryrun) to show what would have been transfered.
The -v option is used so that it displays some feedback
The -r option is used to recurse in subfolders
Title: Re: compare/diff two directory in two different linux/unix machine
Post by: dragoncity99 on October 29, 2009, 03:26:27 PM
If you dont want to do any file changes. But to do investigation.
I suggest you do this:

1. Do "ls -lR /directory > Linux_Directory.txt" on linux. Do the same on Unix.
2. Do a diff -y  on both server.

Alternatively. You can use find command to drill down and dump to a file as well to do the diff.