[Linux-disciples] Rsync Question

Stephen R Laniel steve at laniels.org
Sun Nov 21 22:33:44 EST 2004


On Sun, Nov 21, 2004 at 07:30:38PM -0500, Jason Smith wrote:
> This makes complete sense but is counterintuitive... I'll give it 
> another try when I'm home.

To add maybe nothing to what they wrote, but to elaborate on
bash a little bit for your edification:

When you want to type some character that has a special
meaning in bash, you put quotes around it. E.g., if you
wanted to create a file ".txt -- quote dot txt -- you'd do
something like

touch '".txt'

-- that is, wrap the whole thing in single quotes.
Everything inside the single quotes is taken literally,
rather than in its bash-special meaning. Another way to do
that would be

touch \".txt

The backslash 'escapes' the special character, whereas
putting quotes around the filename escapes *any*
characters in the filename.

The important thing to note is that by the time the command
gets to the program, bash has already stripped away the
escapes. In the 'touch' command above, all that the
program ('touch') sees is

touch ".txt

Now, double the difficulty: I'm uploading a file to
domain.com. The filename contains a space. I need to put
double backslashes around any filename, because *two* copies
of bash -- the one on my end and the one on domain.com's end
-- will be stripping off the quotes. So if I do

rsync domain.com:'file name' .

it'll go through bash on my end and come out

rsync domain.com:file name .

Now once bash on domain.com starts, it won't know what to do with
file name. Whereas if you double the escapes in the command,
to make it

rsync domain.com:'file\ name' .

it'll work fine: it gets through bash on my end and comes out

rsync domain.com:file\ name .

Now 'file name' is a valid file on the other end, and it
downloads fine.

Sorry for the bloviation, but it took me quite a while to
really understand what was going on with these multiple
layers of nesting.

-- 
``[My 3-year-old, Zoe] thought for a moment, and then said,
  `you think George Bush is too stupid to have so much
  wesponsibility?' Yes, child. Exactly that. Plus malice.''
 -http://crookedtimber.org/archives/002857.html



More information about the Linux-disciples mailing list