Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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:… – reinierpost Oct 29 at 12:41

2 Answers 2

up vote 15 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 $TARGET $SOURCE |grep "delet" 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
@Nilis did you really mean to put $TARGET before $SOURCE in the --delete example? – Roberto Franceschini Aug 16 at 9:14
@Chris K right you are. – Nils Sep 29 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 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.