Filenames with blanks

Wayne Davison wayned at users.sourceforge.net
Sat Aug 24 09:45:01 EST 2002


On Sat, 24 Aug 2002, jw schultz wrote:
> Your example does not scan src_host it scans targ_host.

Not so.  If you look carefully at Ivan's quoting, you'll note that
he put the backticks inside single quotes, which saves them for the
$src_host.  For instance:

    COM='`ls -1d f*`'
    rsync -av $src_host:"$COM" /tmp

That command would work just like this simpler command:

    rsync -av $src_host:f\* /tmp

Ivan Kovalev wrote:
> COM='`find '$src_dir'  -mtime -'$days' -type f `'
> rsync -rxlupogtSvve ssh  $src_host:"$COM" $targ_dir

The quoting problem is a shell problem due to the backticks.  Backticks
split the string at spaces, regardless of the quoting or backslashing
that you may attempt to use in the output (which is ignored because the
shell isn't doing parsing there, just word-splitting).  To fix this,
you'll have to affect how the backticks split the output.  I can't
figure out a way to get rsync to set IFS in the right spot to affect
just the backtick expansion, so perhaps the only solution is to use a
different command-running syntax.

If your login shell is zsh, you could use this command:

    COM='${(f)"$(find '$src_dir' -mtime -'$days' -type f)"'

This quotes the find command's output (so that it doesn't get split),
and then explicitly splits the output based on newlines.  I don't know
if bash has something similar (since I don't use bash).

..wayne..




More information about the rsync mailing list