Search code examples
bashrsynccurly-braces

rsync failing with curly braces expansion


I am trying to run the following rsync command:

$ rsync -avz --delete . myuser@myhost:/projects/build{08..40}/

Unexpected remote arg: myuser@myhost/projects/build08/
rsync error: syntax or usage error (code 1) at main.c(1201) [sender=3.0.6]

I do not understand why the command above fails. If I replace build{08..40} with build08, it works.


Solution

  • Expansion of curly braces results in multiple remote locations being passed to rsync.

    rsync -avz --delete . user@host:/dir{1..3}/
    

    becomes

    rsync -avz --delete . user@host:/dir1/ user@host:/dir2/ user@host:/dir3/
    

    which produces the error you are seeing.