LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-01-2005, 06:03 AM   #1
sinc
LQ Newbie
 
Registered: Jul 2005
Posts: 1

Rep: Reputation: 0
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
 
Old 07-01-2005, 07:01 AM   #2
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 61
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Preserving number of links with 'cp'. ( preserve number of links ) Devyn Linux - General 7 09-16-2005 11:07 PM
Automatically Copying files from the ftp directory into the html directory swatward Linux - General 3 04-17-2005 11:55 PM
Preserving directory tree structure /etc/fstab Hikito Linux - Newbie 1 09-11-2004 05:07 PM
copying a CD to a directory MrGardenHoseMan Linux - General 2 07-03-2003 07:51 PM
Copying Symbolic Links ryanstrayer Linux - General 6 02-09-2002 10:37 PM


All times are GMT -5. The time now is 10:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration