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

Matthias Schniedermeyer ms at
Sat Oct 10 12:01:58 MDT 2009

On 10.10.2009 17:43, Andrew Gideon wrote:
> On Sat, 10 Oct 2009 15:54:25 +0200, Matthias Schniedermeyer wrote:
> > It makes a tremendous difference if you have to fork/exec one program
> > per file for, say, 100,000 files. Or (-t here) about 10 instances doing
> > 10,000 files.
> I'm afraid I'm still too obtuse (or perhaps just coffee-deprived) to 
> grasp this.  How does having --target-dir make it possible to copy many 
> files in a single command that was not previously possible?
> Is this still related to xargs use?


In "normal" cp/mv use the last option is the destination. But with 
"standard" xargs all options passed via STDIN are placed after the 
command you provided for execution by xargs. This means you can't 
provide your destination as the last option. "-t" comes to the rescue as 
it allows you to provide the destination beforehand and let xargs fill 
up the rest of the commandline with as many sources as possible(*).

find source | xargs mv -t target

xargs --show-limits

Bis denn

Real Programmers consider "what you see is what you get" to be just as 
bad a concept in Text Editors as it is in women. No, the Real Programmer
wants a "you asked for it, you got it" text editor -- complicated, 
cryptic, powerful, unforgiving, dangerous.

More information about the rsync mailing list