X-Spam-Check-By: sourceware.org Message-ID: <439229AC.1FF59148@dessent.net> Date: Sat, 03 Dec 2005 15:26:36 -0800 From: Brian Dessent <brian AT dessent DOT net> MIME-Version: 1.0 To: cygwin AT cygwin DOT com Subject: Re: bash and variable holding directories with spaces References: <dmt5ls$cvc$2 AT sea DOT gmane DOT org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Reply-To: cygwin AT cygwin DOT com Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com> List-Archive: <http://sourceware.org/ml/cygwin/> List-Post: <mailto:cygwin AT cygwin DOT com> List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com "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 -- 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/