0

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?

4

That's because bash is recognizing them first.

rsync -av "$FROM" "$TO"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.