The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
UNIX; Compare two files abhishek3598 UNIX for Advanced & Expert Users 1 11-06-2007 06:52 PM
Help! Suggestions on what I can I use my 2 unix boxes for? JimmyChang UNIX for Dummies Questions & Answers 3 09-16-2007 12:55 PM
How to direct-connect two UNIX boxes agcodba UNIX for Advanced & Expert Users 3 07-20-2007 06:23 PM
What can I ignore when backing up UNIX boxes? geralex UNIX for Dummies Questions & Answers 4 09-19-2005 03:22 AM
text boxes, radio buttons , check boxes in c++ on unix devy8 High Level Programming 3 07-07-2001 05:58 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-27-2006
flattyre flattyre is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 1
Compare files across 2 UNIX boxes

Is it possible to compare two files which reside on different UNIX boxes?
(I'm using HP POSIX/Korn)

Consider the scenario of a pre-production environment (box 1) and a production environment (box 2) I would like to check if some files on both boxes match or not.

It's quite straightforward on one box:

#----------------------------------------------------
# Function to compares files and display differences
#
# $1 = file1, $2 = file2
#
# cmp with option -s gives the following return codes:
# 0 - identical
# 1 - different
# 2 - inaccessable/other
#----------------------------------------------------
function fn030_compare_file {

cmp -s $1 $2

if [[ $? -gt 0 ]]
then
echo "*** Difference in files! -----> $1 <---> $2"
else
echo "*** OK, Files identical -----> $1 <---> $2"
fi

return
}

The only alternative I can think of is to copy the files to one box, then compare from there.

NOTE: I found an excellent shell script which recursively compares the contents of two directories on one box (to find this do a google search on "cmptree"...)
  #2 (permalink)  
Old 09-27-2006
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,909
You do realize there's already a perfectly good program to compare files without you building your own, right? It's called 'diff'.

As for comparing files on different systems, you could mount a directory from one machine onto another with nfs.
  #3 (permalink)  
Old 09-27-2006
Andrek Andrek is offline
Registered User
  
 

Join Date: Aug 2006
Posts: 122
Basicly you need to get the remote file back to your local system to be able "diff" the two. Mount via nfs, or try a "rcp" to get a copy...

Can't think of a way you can use "diff" on two files where one is local and the other is remote?
Sponsored Links
Closed Thread

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 03:29 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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