Re: bash and variable holding directories with spaces
Almut Behrens wrote:
> On Sat, Dec 03, 2005 at 05:58:28PM -0500, H.S. wrote:
>>Michael Marsh wrote:
>>>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
>>Okay, but this doesn't work:
>>$> ls -nl file*
>>-rw------- 1 1000 1000 0 2005-12-03 16:56 file 1
>>-rw------- 1 1000 1000 0 2005-12-03 16:56 file 2
>>$> DIRS="'file\ 1 file\ 2'"; ls -ln $DIRS
>>ls: 'file\: No such file or directory
>>ls: 1: No such file or directory
>>ls: file\: No such file or directory
>>ls: 2': No such file or directory
>>$> DIRS="'file\ 1 file\ 2'"; ls -ln "$DIRS"
>>ls: 'file\ 1 file\ 2': No such file or directory
> in this case you probably want
> $ DIRS='file\ 1 file\ 2'; eval ls -ln $DIRS
So, here is what I have working now (this all in one line of course):
$> DIRS='/cygdrive/c/Documents\ and\ Settings/user1
/cygdrive/c/Documents\ and\ Settings/user2'; rsync -n -avz
So I set the DIRS variable to the directories which may have spaces in
them and then use that variable in rsync command.
(My plan is to set variables of source directories in a conf file for
the rsync script.)