Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 07-01-2005, 05:03 AM   #1
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?

Old 07-01-2005, 06:01 AM   #2
Senior Member
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 63
The most reliable way I know, that works on most Unix OS (and Cygwin as well) is:
# (cd /source/dir && tar cf - .) | (cd /destination/dir && tar xpf -)
if source and destination already exist.
# (cd /parent/of/source/dir && tar cf - dir/) | (cd /parent/of/destination/dir && tar xpf -)
if destination does not exist yet.



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 10:07 PM
Automatically Copying files from the ftp directory into the html directory swatward Linux - General 3 04-17-2005 10:55 PM
Preserving directory tree structure /etc/fstab Hikito Linux - Newbie 1 09-11-2004 04:07 PM
copying a CD to a directory MrGardenHoseMan Linux - General 2 07-03-2003 06:51 PM
Copying Symbolic Links ryanstrayer Linux - General 6 02-09-2002 09:37 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:46 AM.

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