Filenames with blanks

jw schultz jw at pegasys.ws
Sun Aug 25 00:02:01 EST 2002


On Sat, Aug 24, 2002 at 04:10:57PM -0400, Ivan kovalev wrote:
> Thank you for interesting remark, Wayne.
> 
> I made a test directory with only one file there ("Conference Calls"), so
> that if I run find for files only and quote output, that should be the
> equivalent of the COM you suggested. Still, it gets split on white space.
> You are definetely right about ticks, because if I replace COM for
> explicit quoted filename, that works fine.
> 
> Still, I am not sure if I understand your suggestion. Looks like you are
> saying: have output from COM like this:
> /a/b/c d
> /a/b/efg
> 
> May be each line quoted. And this is exactly what I already have when I
> run this command on the SRC host. Still it is being splitted on white.
> Please clarify if your COM would produce this output or not.
> 
> Ivan

It looks like you are using gnu find.  With gnu find and
bash this will work:

	COM='$(find '$src_dir'  -mtime -'$days' -type f -printf "\'%p\' ")'

Just make sure the quotes get through intact.
This gets find to put quotes around each pathname and $()
keeps them intact.  Backquotes don't work.

> 
>  On Sat, 24
> Aug 2002, Wayne Davison wrote:
> 
> > 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..
> >
> >
> 
> -- 
> To unsubscribe or change options: http://lists.samba.org/mailman/listinfo/rsync
> Before posting, read: http://www.tuxedo.org/~esr/faqs/smart-questions.html

-- 
________________________________________________________________
	J.W. Schultz            Pegasystems Technologies
	email address:		jw at pegasys.ws

		Remember Cernan and Schmitt



More information about the rsync mailing list