anasdox anasdox - 2 years ago 146
Bash Question

How do I move a relative symbolic link?

I have a lot of relative symbolic links that I want to move to another directory.

How can I move symbolic links (ones with a relative PATH) while preserving the right path?

Answer Source

You can turn relative paths into full paths using readlink -f foo. So you would do something like:

ln -s $(readlink -f $origlink) $newlink
rm $origlink


I noticed that you wish to keep the paths relative. In this case, after you move the link, you can use symlinks -c to convert the absolute paths back into relative paths.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download