The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
comparing the content of two directories xyzt UNIX for Dummies Questions & Answers 2 04-29-2008 11:36 AM
Comparing directories via ftp tekster757 UNIX for Dummies Questions & Answers 1 03-21-2008 07:48 AM
comparing 2 Solaris servers melanie_pfefer SUN Solaris 9 03-11-2008 01:29 PM
moving directories to new directories on multiple servers mackdaddy07 Shell Programming and Scripting 0 04-06-2007 12:30 PM
compare directories on two servers MizzGail Shell Programming and Scripting 1 03-25-2003 01:41 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-29-2009
Jazmania Jazmania is offline
Registered User
  
 

Join Date: Feb 2007
Location: Ireland
Posts: 43
Comparing directories on different unix servers

Is it possible to use the diff command to compare two directories on different Unix (AIX) servers?

We have two regions set up and we want to be able to compare if the scripts directory in both regions contain the same files?

I want to figure out if its possible.. Have been messing around by dumping the listing of each dir into separate files and comparing them with diff.. But that doesn't work the way i need it to..

Is there any other command out there that could work?

Thanks,
Jaz

EDIT**

Can something like this work?? I've tried it from the command line but it gives the following error.

ksh: syntax error: `(' unexpected



Code:
diff <(ssh server_name 'cd directory_to_compare; find . -type f -exec {} \;| sort -k 2') <(ssh servername2 'cd directory_to_compare; find . -type f -exec {} \;| sort -k 2') >> diff_report.txt


Last edited by Jazmania; 10-29-2009 at 09:56 PM..
  #2 (permalink)  
Old 10-29-2009
rdcwayx rdcwayx is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 290
don't understand your command, there is no command follow by -exec, if the missed command is ls, then you needn't -exec, use -print (or not, -print is default for find) will export the file list.

Because there is no command for -exec, I don't understand what you sort for.


Code:
diff <(ssh server_name 'find directory_to_compare -type f | sort') <(ssh server_name 'find directory_to_compare -type f | sort')

  #3 (permalink)  
Old 10-30-2009
Jazmania Jazmania is offline
Registered User
  
 

Join Date: Feb 2007
Location: Ireland
Posts: 43
Ok, maybe I don't need the sort.. Just tried


Code:
diff <(ssh paehowup2303 'find /home/x136873 -type f') <(ssh njros1up2303 'find /home/x136873 -type f')

still getting ksh: syntax error: `(' unexpected


I'm running this straight from command line at the minute.. do i need the ' in the command?
  #4 (permalink)  
Old 10-30-2009
rdcwayx rdcwayx is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 290
In which shell do you run the command?

Try if you have bash.


Code:
bash diff <(ssh paehowup2303 find /home/x136873 -type f) <(ssh njros1up2303 find /home/x136873 -type f)

  #5 (permalink)  
Old 10-30-2009
Jazmania Jazmania is offline
Registered User
  
 

Join Date: Feb 2007
Location: Ireland
Posts: 43
Korn shell..

---------- Post updated at 09:37 PM ---------- Previous update was at 04:45 AM ----------

Would it be possible to use the "rsync --dry-run" option to find differences in directories on separate servers.. Only just come across the command and not sure how it works.. The man pages are pretty long.. When comparing the directories can the command work over ssh? I'm can't get my head around how the command works...

Last edited by Jazmania; 10-30-2009 at 05:44 PM..
  #6 (permalink)  
Old 10-31-2009
steadyonabix steadyonabix is online now
Registered User
  
 

Join Date: Oct 2009
Location: UK
Posts: 188
In Korn shell I would expect something more like this: -


Code:
diff <$(ssh paehowup2303 'find /home/x136873 -type f')  <$(ssh njros1up2303 'find /home/x136873 -type f')

The $ gets rid of the unexpected ( error but I think it still wont work as the diff is expecting file names
  #7 (permalink)  
Old 10-31-2009
Scrutinizer Scrutinizer is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 761
No, the syntax is correct with the <(..) constructs. Jazzmania, my guess would be that you are running ksh88 on the system you are firing the command from. What happens if you run this:

Code:
(echo ${.sh.version}) 2>&- || echo ksh88

Perhaps /bin/ksh93 is present on your system too. If so try start up that shell and try running the command from there.

Quote:
Originally Posted by Jazmania View Post
.. do i need the ' in the command?
No, you can leave them out.

Last edited by Scrutinizer; 10-31-2009 at 07:28 PM..
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:35 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0