[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: cp command



Syd Alsobrook wrote:
>
> Really easy
>
> The best way to copy a directory tree from one drive to another is
>
>         cp -pr /usr /hd
>
> Thanks
>
> Syd
> ----

Hmm... The _best_ way?  I not so sure.  Like most things in
*nix where there are lots of ways to get the job done there
is usually not a _best_ way.  A major problem with cp -pr is
that linked-files, both hard and soft, are broken and all
links are copied individually as regular files.  This can
cause MAJOR problems as well as consuming more disk space.

A couple of ways to avoid this problem are:

mkdir newDir
cd oldDir
find . -print | cpio -pdm newDir

    OR

mkdir newDir
cd newDir
(cd oldDir;tar cf - .) | tar xpf -

I'm sure these are not the _best_ way, but as far as I know
there are no hidden side-effects with links, permissions,
etc.

My $0.02
--Bob
--- Begin Message ---
Syd Alsobrook wrote:
> 
> Really easy
> 
> The best way to copy a directory tree from one drive to another is
> 
>         cp -pr /usr /hd
> 
> Thanks
> 
> Syd
> ----

Hmm... The _best_ way?  I not so sure.  Like most things in
*nix where there are lots of ways to get the job done there
is usually not a _best_ way.  A major problem with cp -pr is
that linked-files, both hard and soft, are broken and all
links are copied individually as regular files.  This can
cause MAJOR problems as well as consuming more disk space.

A couple of ways to avoid this problem are:

mkdir newDir
cd oldDir
find . -print | cpio -pdm newDir

    OR

mkdir newDir
cd newDir
(cd oldDir;tar cf - .) | tar xpf -

I'm sure these are not the _best_ way, but as far as I know
there are no hidden side-effects with links, permissions,
etc.

My $0.02
--Bob

--- End Message ---

Reply to: