Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

I have a folder.

I have one copy of this folder locally and one on a server. I edited my local folder as I wanted and then rsync it to the server.

Is there any way of comparing those two copies, local and remote, and get back a list of files that are on the remote one and not the local one?

share|improve this question
up vote 2 down vote accepted

The following rsync command executed on the local machine lists the files that exist on the remote host but not the local host.

rsync -av --dry-run --delete somedir/ user@remote:~/somedir/

The --dry-run switch only lists the files, without actually doing something, the --delete switch in combination with -v (verbose) lists the files that would be deleted because they exist on the remote host, but not the local host, which is want you want.

share|improve this answer

Unison File Synchronizer does exactly that using the rsync algorithm for the heavy lifting. I use it daily.

share|improve this answer

If you already have ssh keys to do your rsync, you could issue a remote ssh command and list the files in the dir, then diff it with a copy from your local dir.

ssh user@remote.com ls -1 ~/foo > /tmp/remote.txt && ls -1 ~/foo > /tmp/local.txt && diff /tmp/remote.txt /tmp/local.txt

Extra credit, pipe the output of diff to colordiff for prettiness.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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