i have one file which exists in 2 different unix machines. how i can compare the data with in the file
Asked
Active
Viewed 2,744 times
4 Answers
6
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.

ooshro
- 11,134
- 1
- 32
- 31
-
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
1
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.

Hrvoje Špoljar
- 5,245
- 26
- 42
-
`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.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
1
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.

rems
- 2,260
- 13
- 11
0
vimdiff file scp://login@server//pathto/file
the double / after server is not a typo

Michael Hampton
- 244,070
- 43
- 506
- 972

slamp
- 1
- 1