Super User is a question and answer site for computer enthusiasts and power users. 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

An excerpt from a bash script I'm using to backup some photos:


FROM="/cygdrive/f/\"Trip to Austria\""
TO="/cygdrive/s/\"Trip to Austria\""

rsync -av $FROM $TO

When I print the final command from inside the script it prints properly, i.e.,

rsync -av /cygdrive/f/"Trip to Austria" /cygdrive/s/"Trip to Austria"

However, the command doesn't work when I run the script. The error I get relates to the spaces in the paths not being recognized.

rsync: link_stat "/cygdrive/f/Photos/"Trip" failed: No such file or directory (2)
rsync: link_stat "/home/User/to" failed: No such file or directory (2)
rsync: change_dir "/home/User/Austria"" failed: No such file or directory (2)

Strangely though, the command does work when I type it out in the Cygwin shell.

What gives?

share|improve this question
up vote 4 down vote accepted

That's because bash is recognizing them first.

rsync -av "$FROM" "$TO"
share|improve this answer
Ah, that was it! Thank you. – Yony Oct 20 '11 at 23:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .