3

If I have a folder with several files on my computer, and a copy of the same folder on a remote server, is it possible to run 'diff' through ssh so I can see the differences between my copy and the one on the remote server? Ideally, I'd like to see if there are any additional/less files in either copy of the folder and then check to see if the individual files themselves have any differences.

3

To see if there are any additional/less files in either copy of the folder

diff -y <(ssh user@remote_server 'ls -1aR /remote_folder/') <(ls -1aR /local_folder/)
2

diff only works with local files. You might use scp or rsync to copy the files to a local directory and compare it with diff, or you can use something like sshfs to mount a remote directory to a local one and compare it with the second one.

For a single file, you can use ssh and diff:

ssh user@machine cat remote-file | diff - local.file
  • Is there no ssh equivalent of diff? This would work... but it seems to me that someone else would have wanted the same thing, and hopefully done it. :P Thanks, though! – Kitchi Oct 29 '12 at 12:30
0

An alternative to find which files differ is to use rsync, as described in https://serverfault.com/a/16665/317052. Use

rsync -anicu  . user@remote_host:directory/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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