X-Spam-Check-By: sourceware.org
To: cygwin@cygwin.com
From: "H.S." <hs.samix@gmail.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@sea.gmane.org> <439229AC.1FF59148@dessent.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@cygwin.com; run by ezmlm
Precedence: bulk
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie.com@cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.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/

