How do I move/copy a symlink to a different folder as a symlink under Solaris?

18,975

Solution 1

I believe the "-d" argument is what you need.

As per the cp man page:

-d     same as --no-dereference --preserve=link

Example:

cp -d -R -P link folder/new_link

I was using "cp -d" and that worked for me.

Solution 2

The cp man page seems to say that you want to use an '-H' to preserve symlinks within the source directory.

Share:
18,975
kadeshpa
Author by

kadeshpa

Work on Unix/Linux platform and drives me to learn more and more about these OS.

Updated on June 05, 2022

Comments

  • kadeshpa
    kadeshpa almost 2 years

    It is an odd behaviour seen only on Solaris that when I try to copy a symbolic link with the "cp -R -P" command to some other folder with a different name, it copies the entire directory/file it's pointing to.

    For example:

    link -> dir
    
    cp -R -P link folder/new_link