[PLUG] Proper way to copy directories

Rich Burroughs rich at paranoid.org
Wed Dec 22 18:39:52 UTC 2004


Richard C. Steffens wrote:
> Re-reading info coreutils cp, I discovered that I should have use the -p 
> option to preserve the attributes. However it's still a little fuzzy, so 
> here's today's question: is this the form of the cp command I should have 
> used?
> 
> cp -r -p all /home/rsteff /home2
> 
> (The only directory in /home is rsteff.)
> 
> Or, is there another command I should be using?

Hi Richard,

Sounds like you've seen this, but here's a man page:

http://www.zevils.com/cgi-bin/man/man2html?1+cp

For the kind of thing you're doing, I'd usually use the -a option, which 
is the same as -dpR.

Try:

   cp -a /home/rsteff /home2

Another option would be to use tar if you're more comfortable with that. 
In /home do:

   tar cvf /home2/rsteff.tar rsteff

That will create a tarball in the /home2 directory that has the rsteff 
directory in it.

   cd /home2
   tar xvf rsteff.tar

You might do "tar tvf rsteff.tar" first, to make sure that what you're 
extracting looks right and is in the right place.


Rich

p.s. I'm very tired right now, so be careful using my suggestions ;)






More information about the PLUG mailing list