0e1cec521e6770be8ce89bb119c48ed7011804e3
3 # inspired by https://stackoverflow.com/questions/8523159/how-do-i-move-a-relative-symbolic-link#8523293
4 # by Christopher Neylan
7 echo 'usage: mv_ln src_ln dest_dir'
10 echo ' Move the symbolic link src_ln into dest_dir while'
11 echo ' keeping it relative'
15 [ "$1" == "--help" ] ||
[ ! -L "$1" ] ||
[ ! -d "$2" ] && help
17 set -e # exit on error
20 orig_name
=$
( basename "$orig_link" )
21 orig_dest
=$
( readlink
-f "$orig_link" )
24 ln -r -s "$orig_dest" "$dest_dir/$orig_name"