1753679 Members
5638 Online
108799 Solutions
New Discussion юеВ

Re: Diff command

 
SKR_1
Trusted Contributor

Diff command

Hi

Can we use diff command to differentiate files on two servers.

Thanks

SKR
13 REPLIES 13
Dennis Handly
Acclaimed Contributor

Re: Diff command

You can only do this if one file is over NFS and you use that path.
SKR_1
Trusted Contributor

Re: Diff command

Hi Dennis,

Can you give me one line script which will cat the file from other server with doing ssh/rmesh/rsh and can be diff with file present on current server.

Thanks

SKR
Venkatesh BL
Honored Contributor

Re: Diff command

If you want to compare a local '/tmp/abc' file with the same file in another server 'xyz', you could do:
1) rcp xyz:/tmp/abc /tmp/abc.xyz
2) diff /tmp/abc /tmp/abc.xyz

Once done, you could delete the 'abc.xyz' file from the local machine.

This is one way. If you can NFS mount this directory from the other server, then you can directly do:
# diff /tmp/abc /mntpoint-of-server-dir/abc
Dennis Handly
Acclaimed Contributor

Re: Diff command

>Can you give me one line script which will cat the file from other server with doing ssh/remsh/rsh and can be diff with file present on current server.

Ah, right you can do that:
remsh remote -n "cat remote-file-path" | diff - local-file-path
SKR_1
Trusted Contributor

Re: Diff command

Hi Dennis,

Still i am not able to diff these files.

I am able to cat the file, but diff is not working.

Thanks

SKR
Steven E. Protter
Exalted Contributor

Re: Diff command

Shalom,

I have always used diff in one of two ways:

1) took a copy of the files and ran it local
2) Established an nfs connection.

Note that you can not use diff successfully on binary files

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Dennis Handly
Acclaimed Contributor

Re: Diff command

>I am able to cat the file, but diff is not working.

I assume you can do:
remsh remote -n "cat remote-file-path" | more

What command did you use? What do you mean "not working"? I hope you kept that "-" I had.
Dennis Handly
Acclaimed Contributor

Re: Diff command

>SEP: Note that you can not use diff successfully on binary files

If you consider "success" as an exact match or just knowing the files are different, you can.
Kapil Jha
Honored Contributor

Re: Diff command

what command exactly you are running ,have you copied the file locally,what is the error you are getting.

diff file1 file2
is the command.

Thanks,
Kapil+
I am in this small bowl, I wane see the real world......