Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 need some help in this issue:

I want sync /path/first/ with /path/second/, /path/third/ ..etc

so I've tried this:

rsync -rv /path/first/ /path/{second,third,fourth}/

But it worked only for last directory. What's wrong? Thanks.

share|improve this question

migrated from Jan 11 '13 at 20:50

This question came from our site for professional and enthusiast programmers.

Those braces are NOT interpreted by rsync but by the shell. – fge Jan 11 '13 at 20:04

rsync only takes one target. Use a for loop instead.

for dest in {second,third,fourth}
  rsync -rv /path/first/ /path/"$dest"/
share|improve this answer
Got it, thanks. – loadaverage Jan 11 '13 at 21:40

How about it?

for qw in `ls -d /path/*`; do  rsync -rv /path/first /path/$qw; done
share|improve this answer
I count 3 bugs. 4, if you want to be picky. – Ignacio Vazquez-Abrams Jan 11 '13 at 20:13
what do you mean? – Satish Jan 11 '13 at 20:18
First you should never attempt to loop ls output with for. Your script breaks if any of the folders contains a space in their path. Also you need to quote the variable for similar reasons. Pipe find … -print0 through while IFS= read -r -d '' file; do … "$file"; done, or so to be safe. – slhck Jan 11 '13 at 21:40

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.