November 25, 2024, 01:24:06 PM

News : LinuxSolved.com Linux Help Community Forum..


Author Topic: compare/diff two directory in two different linux/unix machine  (Read 17896 times)

Offline chuikingman

  • Linux Noob !
  • *
  • Posts: 6
compare/diff two directory in two different linux/unix machine
« 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

Offline pedro

  • Linux Noob !
  • *
  • Posts: 14
Re: compare/diff two directory in two different linux/unix machine
« Reply #1 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.

Offline neko

  • New Member
  • Posts: 1
Re: compare/diff two directory in two different linux/unix machine
« Reply #2 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

Offline dragoncity99

  • LST CareTaker
  • Experienced
  • *****
  • Posts: 551
Re: compare/diff two directory in two different linux/unix machine
« Reply #3 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.