[plug] Copying a directory tree without the files

Russell Steicke r.steicke at bom.gov.au
Thu Jan 10 17:44:25 WST 2002


On Wed, Jan 09, 2002 at 11:55:45PM +0800, James Bromberger wrote:
> On Wed, Jan 09, 2002 at 11:45:56PM +0800, Matt Kemner wrote:
> > > b) copy the tree (minus the files) to a template location.
> > for X in `find /source_dir -type d`
> > do
> >   mkdir /target_dir/$X
> > done
> 
> cd /source_dir; find . -type d -exec mkdir /dest_dir/{} \;

Safer and quicker:

  $ cd /target
  $ ( cd /source && find . -type d -print0 ) | xargs -0 mkdir -p

Handles directory names with spaces and newlines etc in their names, and
doesn't exec mkdir for every name.


-- 
Russell Steicke

-- Fortune says:
Every cloud engenders not a storm.
		-- William Shakespeare, "Henry VI"



More information about the plug mailing list