LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   copying a directory and preserving links? (https://www.linuxquestions.org/questions/linux-newbie-8/copying-a-directory-and-preserving-links-338994/)

sinc 07-01-2005 05:03 AM

copying a directory and preserving links?
 
I'm trying to copy an entire directory structure and preserve any links. What would the correct syntax be?
cp -rp *.* /dev/hdb2?

or is there a better way?

Thanks

theYinYeti 07-01-2005 06:01 AM

The most reliable way I know, that works on most Unix OS (and Cygwin as well) is:
Code:

# (cd /source/dir && tar cf - .) | (cd /destination/dir && tar xpf -)
if source and destination already exist.
Else:
Code:

# (cd /parent/of/source/dir && tar cf - dir/) | (cd /parent/of/destination/dir && tar xpf -)
if destination does not exist yet.

Yves.


All times are GMT -5. The time now is 07:56 AM.