[ILUG] copying files

Dave Neary dave.neary at palamon.ie
Fri Apr 6 14:15:08 IST 2001


"John P. Looney" wrote:
> 
> On Fri, Apr 06, 2001 at 02:00:20PM +0100, Paul Askins mentioned:
> > Does anybody know of a way to copy all files recursively from one directory to
> > another without re-creating the original dir structure.  I'm sure tar can
> > prolly do this but can't figure out how, everything I try just keeps
> > re-creating the original dir structure.
> > Any help appreciated,
> 
>  Find is your friend;
> 
>     find /dir -name -type f \* -exec cp -a {} /target/dir \;
> 
>  That'll copy every file in /dir into /target/dir, preserving
> attributes...

Tar is also usable - 
    cd /dir && tar cfz - . | (cd /target/dir && tar xvfz -)

Why the empty -name flag to find? Why not just leave it out?

I'm assuming that by "Not get the original structure" you mean that you
don't want to copy /dir to /new_dir and get /new_dir/dir? If you don't
want *any* directory structure, Kate's method works.

> Kate

Cheers,
Dave.

-- 
David Neary,               E-Mail dave.neary at palamon.ie
Palamon Technologies Ltd.  Phone +353-1-634-5059




More information about the ILUG mailing list