Thursday, January 22, 2009
I have already discussed how we can edit a remote file using vi and scp in one of my previous post ; today we will see how we can find or show differences between a local file and a remote file using ssh.
Suppose we have to find the differences between local file "/tmp/filepurge.sh.old" and remote file "/root/scripts/filepurge.sh" located in remote host 172.21.16.11.
This is how can do it:
$ ssh email@example.com "cat ~/scripts/filepurge.sh" | diff - /tmp/filepurge.sh.old
And using vimdiff:
$ vimdiff scp://firstname.lastname@example.org//root/scripts/filepurge.sh /tmp/filepurge.sh.old
** We would need ssh to work using public key authentication so that we can do remote commands execution without being prompted for passwords.
© Jadu Saikia www.UNIXCL.com