DISQUS

DISQUS Hello! Tech-Recipes is using DISQUS, a powerful comment system, to manage its comments. Learn more.

Community Page

Tech-Recipes

Cookbook of Tech Tutorials
Jump to original thread »
Author

Copy entire contents of a directory and preserve permissions | Solaris | Tech-Recipes

Started by qdideas · 9 months ago

No excerpt available. Jump to website »

5 comments

  • what's wrong with cp -Rp dir1 dir2 ?
  • 'cp -Rp' is not supported on most Unixes. '-Rp' flags are only supported by the version of 'ls' that comes with the GNU Core-utils, which is not installed everywhere.

    The tar command will work on all versions of Unix.
  • In addition, I think you meant 'cp -a', which is equivilant to 'cp -dpR'. The -d flag will dereference 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 id="quote"><h6>flarg wrote:</h6>In addition, I think you meant 'cp -a', which is equivilant to 'cp -dpR'. The -d flag will dereference 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>
  • cp uses a caracter for caracter copy method. copying with tar is faster because is uses greater buffers

Add New Comment

Returning? Login