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

kadeshpa picture kadeshpa · Apr 2, 2009 · Viewed 18.4k times · Source

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

Answer

LokMac picture LokMac · Nov 9, 2011

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.