gnu --target-dir, how to fake with rsync?

Matt McCutchen matt at mattmccutchen.net
Sun Oct 11 02:26:38 MDT 2009


On Wed, 2009-10-07 at 04:40 -0700, Martin Scharrer wrote:
> I agree with both above points. However, I would also vote for adding such
> an option to rsync.
> This should not be to difficult and would come in handy.

I'm not convinced of the need for a --target-dir option.  Do you have an
example in which it would be significantly cleaner than --files-from?

> About the mentioned use of the option --files-from:
> Sanjeev's earlier example:
> 
>   find ./ -type file -mindepth 3 -print0 | xargs -r0 cp
> --target-dir=/home/sam/stuff/otherstuff/morestuff -
> 
> can be adapted to rsync like this:
> 
>   rsync -0 --files-from=<(find ./ -mindepth 3 -type f -print0)
> /home/sam/stuff/otherstuff/morestuff
> 
> if you are using the BASH shell. Otherwise you have to write the output of
> 'find' into a temp file and use this for --files-from.

No, you can use stdin, as the man page description of --files-from
mentions:

find ./ -mindepth 3 -type f -print0 \
	| rsync -0 --files-from=- /home/sam/stuff/otherstuff/morestuff

-- 
Matt



More information about the rsync mailing list