use rsync with filenames containing "-"

John Van Essen vanes002 at
Wed Oct 8 22:18:05 EST 2003

On Wed, 8 Oct 2003, <joerg.maier at> wrote:
> Hey there,
> when i try to sync two directories or files containing a "-" character
> in ther path, rsync fails:
> # /usr/bin/rsync --partial -rcvaLe "ssh -o UserKnownHostsFile=/dev/null -o \
> StrictHostKeyChecking=no" --progress "user at server:/path/band - album/" "/path/"
> this gives an error like:
> rsync: on remote machine: -: unknown option
> every escaping like \- or \\- fails, too. Any help is appreciated.
> joerg maier

The dash isn't your problem.  It's the spaces.  The command being sent
to the remote isn't including the quotes and isn't escaping the spaces,
so the "user at server:/path/band - album/" becomes three tokens, and the
'-' by itself causes the error.

Try substituting one of these (note single vs. double quotes):

  'user at server:/path/band\ -\ album/'
  "user at server:/path/band\\ -\\ album/"
  'user at server:"/path/band - album/"'
  "user at server:'/path/band - album/'"

This might work, too:

  "user at server:/path/band\ -\ album/"

But I'd go with the first one, above.

Good luck.
        John Van Essen  Univ of MN Alumnus  <vanes002 at>

More information about the rsync mailing list