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

Is it possible to compare two directories with rsync and only print the differences? There's a dry-run option, but when I increase verbosity to a certain level, every file compared is shown.

ls -alR and diff is no option here, since there are hardlinks in the source making every line different. (Of course, I could delete this column with perl.)

share|improve this question
Similar: serverfault.com/questions/62364/… – reinierpost Oct 29 '15 at 12:41
up vote 20 down vote accepted

You will propably have to run something like rsync -avun --delete in both directions.

But what are you actually trying to accomplish?


rsync -avun --delete $SOURCE $TARGET |grep "^deleting " will give you a list of files that do not exist in the target-directory.

"grep delet" because each line prints : deleting ..file..

rsync -avun $SOURCE $TARGET will give you a list of "different" files (including new files).

share|improve this answer
I want to list all files that are in the source but not in the target directory. All modified files should be listed too. – chris Dec 3 '12 at 18:55
@chris I updated my answer. Is this what you are searching for? – Nils Dec 4 '12 at 21:26
Yes that's it. Thank you. – chris Dec 6 '12 at 17:23
The grep should be on "^delet" as that text string appeared in a few dozens of files from a RAID I am copying. But only 11 started with deleting – Chris K Sep 27 '15 at 23:13
@Chris K right you are. – Nils Sep 29 '15 at 19:59

To add to Nils's answer (for anyone coming across this via Google), by default rsync only compares the file sizes and modification times to tell if there are any differences. (If those are different it does more, but if they're the same, it stops there.)

If you want to compare actual file contents, even for files which have the same size and last modification time, add the flag -c to tell rsync to compare the files using a checksum.

rsync -avnc $SOURCE $TARGET

(The -u option tells rsync to ignore files which are newer in $TARGET than on $SOURCE, which you probably don't want if you're comparing contents.)

share|improve this answer
Thank you for adding this. – chris Jan 8 '15 at 17:00

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.