Copy a Symbolic Link on Linux

The Problem:
I can't use cp to copy a symlinks to a directory, but i don't want to re-create it which could lead to typo problem due to long target path.

The Solution:
After quick search i found two working ways to do it.

First,
you still need to re-create then link but doesn't have to re-type target path, use readlink output instead.

ln -s `readlink ~/v1/jboss-deploy` ~/v2/jboss-deploy

In above command the `jboss-deploy` is a symlink to a directory somewhere in this box.




Second,
just use -P option on cp


cp -P ~/v1/jboss-deploy ~/v2/

well, then i should admit that i never read cp manual carefully... =="

No comments:

Post a Comment