Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

i have one file which exists in 2 different unix machines. how i can compare the data with in the file

share|improve this question
add comment

4 Answers 4

You can compare files remotely using ssh:

$ ssh -p 2022 localhost "cat /remote_path" | diff - /local_path
$ ssh -p 2022 localhost "cat /etc/lsb-release" | diff - /etc/lsb-release
2,4c2,4
< DISTRIB_RELEASE=10.10
< DISTRIB_CODENAME=maverick
< DISTRIB_DESCRIPTION="Ubuntu 10.10"
---
> DISTRIB_RELEASE=10.04
> DISTRIB_CODENAME=lucid
> DISTRIB_DESCRIPTION="Ubuntu 10.04.2 LTS"

Or use sshfs/nfs.

share|improve this answer
    
hi, thanks for your reply . actually i have list of files in one directory in 2 unix boxes . i need to compare all the files data between 2 unix boxes. how i can do for list of files data comparision in unix . –  Navadeep Feb 17 '11 at 11:26
1  
@Navadeep Use sshfs and 'diff -r' –  ooshro Feb 17 '11 at 11:55
add comment

shortest way to figure if they are 'same' could be

md5sum file on each box, and compare if md5sums match (or some other sum)

if you want to diff them , copy one file over to other box and diff it.

share|improve this answer
    
md5sum isn't a way «to figure if they are 'same'». It's rather a way to figure out whether they're different, ЕВПОЧЯ. :-) –  poige Feb 17 '11 at 11:15
    
hi,thanks for your reply –  Navadeep Feb 17 '11 at 11:18
    
hi,thanks for your reply.actually i dont have write access in another unix box .i can only check the file data is same or not if the data is not same i need to send a mail.... –  Navadeep Feb 17 '11 at 11:21
add comment

Remotely? Do you have NFS running? Is the directory containing the file of one of the machines mounted on the other machine? You could check this with " df ".

If you don't have NFS or the directory is not mounted you will have to copy the file. You could use " scp " to copy the file.

For comparing them use diff or if installed kdiff3 or mgdiff are nice. " diff -y " shows a side by side output.

share|improve this answer
add comment
vimdiff file scp://login@server//pathto/file

the double / after server is not a typo

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.