delorie.com/archives/browse.cgi | search |
X-Spam-Check-By: | sourceware.org |
To: | cygwin AT cygwin DOT com |
From: | "H.S." <hs DOT samix AT gmail DOT com> |
Subject: | Re: bash and variable holding directories with spaces |
Date: | Sat, 03 Dec 2005 18:52:19 -0500 |
Lines: | 40 |
Message-ID: | <dmtb3l$org$1@sea.gmane.org> |
References: | <dmt5ls$cvc$2 AT sea DOT gmane DOT org> <439229AC DOT 1FF59148 AT dessent DOT net> |
Mime-Version: | 1.0 |
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 |
List-Unsubscribe: | <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com> |
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 |
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/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |