AllExperts > Experts 
Search      

Sun Operating System

Volunteer
Answers to thousands of questions
 Home · More Questions · Answer Library  · Encyclopedia ·
More Sun Operating System Answers
Question Library

Ask a question about Sun Operating System
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Kenneth Gullberg
Expertise
Experienced unix admin, Nis+, Clearcase, Veritas, Legato, Sendmail, etc etc.

Experience
I work as senior unix system specialist

Organizations
Centus

 
   

You are here:  Experts > Computing/Technology > Focus on PC Support > Sun Operating System > copying soft links

Topic: Sun Operating System



Expert: Kenneth Gullberg
Date: 8/26/2004
Subject: copying soft links

Question
Hello,
I am trying to duplicate certain small portions of a disk which includes directories, files and soft-links. But when I use "cp [options]" it seems that the soft-link target is copied rather than the soft-link as it is. Is there some switch (or some other way) to copy a small directory structure such that the soft-links will be retained?
What I would like is a mirror image.

Thanks in advance.

Answer
Hi!

The easiest way to copy something like that is to use tar.

Lets say you want to copy dir1 to dir2 (with symlinks and all):

(both dir1 and dir2 needs to exist)

cd dir1
tar cvfp - . | ( cd ../dir2; tar xvf - )

Done.

Good Luck!

// Kenneth

Add to this Answer    Ask a Question



  Rate this Answer
   Was this answer helpful?
Not at allDefinitely              
   12345  

     
About Us | Advertise on This Site | User Agreement | Privacy Policy | Help
Copyright  © 2008 About, Inc. About and About.com are registered trademarks of About, Inc. The About logo is a trademark of About, Inc. All rights reserved.