[plug] Recursive Copying of Folder Contents

Alastair Irvine alastair at al.id.au
Thu Jun 4 23:09:35 WST 2009


On Wed, 2009-06-03 at 19:16 +0800, William Kenworthy wrote:
> something like:
> 
> "/usr/bin/find /topoftree -type f -exec cp {}  /fullpathtodestination \;"
> 
> Going from memory - check arguments to your version of find.

A better alternative is the following, as it doesn't suffer from
command-line length limits or interesting characters (e.g. spaces) in
filenames:
 find /topoftree -type f -print0 | xargs -0 cp --target-directory=/dest

This uses an GNU cp option that lets you specify the target, rather than
putting it as the last argument.  I'm fairly sure this option was
designed for the above usage.




More information about the plug mailing list