Re: bash and variable holding directories with spaces
On 12/3/05, H.S. <email@example.com> wrote:
> In the script, I am faced with this problem of defining the source
> directories (dirs on the remote machine to be backed up) in a bash
> variable. I want to define a variable DIRS so that it expands to:
> '/cygdrive/c/Documents\ and\ Settings /cygdrive/d/My\ Data'
> *with* the quotes, to copy "/cygdrive/c/Documents and Settings" and
> "/cygdrive/d/My Data" to my local machine. I want to use this variable
> in the rsync command, like so:
> rsync -av remotehost:$DIRS /mnt/backups
> I have tried a few ways to define the DIRS variable, but I am able to
> get quotes in the expanded value of the variable.
If I understand the behavior you want correctly, then
DIRS="'/cygdrive/c/Documents\ and\ Settings /cygdrive/d/My\ Data'"
works for me.
This also works for constructions like
Michael A. Marsh