Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 3 down vote accepted

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/)
share|improve this answer

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
share|improve this answer
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

An alternative to find which files differ is to use rsync, as described in Use

rsync -anicu  . user@remote_host:directory/
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .