-
Website
http://www.tech-recipes.com/ -
Original page
http://www.tech-recipes.com/rx/513/copy-entire-contents-of-a-directory-and-preserve-permissions/ -
Subscribe
All Comments -
Community
-
Top Commenters
-
davak
83 comments · 1 points
-
danishbacker
9 comments · 1 points
-
flexinfo
11 comments · 1 points
-
bej
4 comments · 1 points
-
dimithri
5 comments · 1 points
-
-
Popular Threads
-
Windows 7: How to Prevent the Mouse from Waking your PC
1 week ago · 2 comments
-
Outlook 2010: Turn Off Attachment Preview
2 weeks ago · 2 comments
-
Gmail: How to Send SMS Messages Without Using Email
3 weeks ago · 2 comments
-
Thunderbird 3: How to Download Images Automatically
2 weeks ago · 1 comment
-
Windows 7 – Prevent Live Messenger from Opening at Start Up
2 weeks ago · 1 comment
-
Windows 7: How to Prevent the Mouse from Waking your PC
The tar command will work on all versions of Unix.
'cp -Rp dir1 dir2' doesn't preserve symlinks. It will instead copy the contents of the target:
If dir1 looks like this:
-rw-r--r-- 1 flarg group 0 Aug 17 14:59 file1
lrwxrwxrwx 1 flarg group 4 Aug 17 14:59 link1 -> /tmp
If you use 'cp -Rp', then 'link1' will become a directory:
cp -Rp dir1 dir2
-rw-r--r-- 1 flarg group 0 Aug 17 14:59 file1
drwxrwxrwx 7 flarg groupl 1701 Aug 17 14:59 link1
You really want the '-d' flag to dereference any symbolic links.
'cp -Rp dir1 dir2' doesn't preserve symlinks. It will instead copy the contents of the target:
If dir1 looks like this:
-rw-r--r-- 1 flarg group 0 Aug 17 14:59 file1
lrwxrwxrwx 1 flarg group 4 Aug 17 14:59 link1 -> /tmp
If you use 'cp -Rp', then 'link1' will become a directory:
cp -Rp dir1 dir2
-rw-r--r-- 1 flarg group 0 Aug 17 14:59 file1
drwxrwxrwx 7 flarg groupl 1701 Aug 17 14:59 link1
You really want the '-d' flag to dereference any symbolic links.</ul>