Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

#!/bin/bash

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.