![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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"...) |
|
||||
|
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. |
|
||||
|
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 | ||
|
|