I have a lot of relative symbolic links that I want to move to another directory.
How can I move symbolic links (those with a relative path) while preserving the right path?
I have a lot of relative symbolic links that I want to move to another directory.
How can I move symbolic links (those with a relative path) while preserving the right path?
One can use
tar
to move a folder containing relative symbolic links.For example:
Improving on Christopher Neylan's answer:
This is also part of https://github.com/tpo/little_shell_scripts
This is a
perl
solution that preserves relative paths:You can turn relative paths into full paths using
readlink -f foo
. So you would do something like:EDIT:
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.