X-Spam-Check-By: sourceware.org To: cygwin AT cygwin DOT com From: "H.S." Subject: Re: bash and variable holding directories with spaces Date: Sat, 03 Dec 2005 18:52:19 -0500 Lines: 40 Message-ID: References: <439229AC DOT 1FF59148 AT dessent DOT net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20051007 Debian/1.7.12-1 In-Reply-To: <439229AC.1FF59148@dessent.net> X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Brian Dessent wrote: > "H.S." 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. > > > You have to quote $DIRS when you use it otherwise it will be expanded > into multiple words. > > DIRS='/cygdrive/c/Documents\ and\ Settings /cygdrive/d/My\ Data' > rsync -av "remotehost:$DIRS" /mnt/backups > > If it were me I think I'd just use mount to get rid of the spaces. > > Brian > Yup, it works perfectly: $> DIRS='/cygdrive/c/Documents\ and\ Settings/user1 /cygdrive/c/Documents\ and\ Settings/user2'; rsync -n -avz --exclude=Application* --exclude=Local?Sett* "ice:$DIRS" ./ Thanks a ton. BTW, how to use mount to deal with spaces? ->HS -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/