Some file copying help please

Rick Stevens rstevens at vitalstream.com
Wed Apr 20 00:02:33 UTC 2005


Waldher, Travis R wrote:
>>DOH!  Try:
>>
>>	cd /dir1
>>	cp -a --parents dir2/dir3/dir4 /dir5
>>
>>(stupid!)
> 
> 
> THANKS!!
> 
> Sometimes the obvious just escapes me.  If you heard a bang! That was my
> head hitting the desk after reading the paths you just wrote.

Heheheheh!  Been there.  Done that.  Have the concussion to prove it!

:-D

> So, -a, what exactly does archive mean?  I was using -R and -p.

All "-a" adds to "-pR" is that cp should NOT dereference symlinks.  That
means it should copy symlinks as symlinks, not as the files they
reference.  I think it does modify relative symlinks so they point at
the right target if they cross paths, however.  I'd have to check that.

Anyway, deconvolving the whole mess:

	"-a" = "-dpR"
	"-d" = "--no-dereference --preserve=link"
	"-p" = "--preserve=mode,ownership,timestamps"
	"-r" = "--recursive"

Since "-d" includes part of "--preserve", but "-p" adds the rest, you
can consider these commands as identical:

	cp -a
	cp -dpR
	cp --no-dereference --preserve=all --recursive

"cp -a" is just easier to type.
----------------------------------------------------------------------
- Rick Stevens, Senior Systems Engineer     rstevens at vitalstream.com -
- VitalStream, Inc.                       http://www.vitalstream.com -
-                                                                    -
-        Change is inevitable, except from a vending machine.        -
----------------------------------------------------------------------




More information about the Redhat-install-list mailing list