]>
zdv2.bktei.com Git - BK-2020-03.git/blob - unitproc/bkmvln
   2 # Desc: Moves sybolic link 
   4 # Input: arg1: path of existing symbolic link 
   5 #        arg2: path where link should be moved 
   7 # Depends: gnucoreutils 8.30 
   9 #  1. Christopher Neylan. https://stackoverflow.com/questions/8523159/how-do-i-move-a-relative-symbolic-link#8523293 
  10 #  2. Tomáš Pospíšek. https://stackoverflow.com/a/30508868 
  13    echo 'usage: mv_ln src_ln dest_dir' 
  16    echo '  Move the symbolic link src_ln into dest_dir while' 
  17    echo '  keeping it relative' 
  21 # Show help if `--help` flag given, if arg1 isn't a symbolic link, or 
  22 #   if arg2 isn't a directory. 
  23 [ "$1" == "--help" ] || 
[ ! -L "$1" ] || 
[ ! -d "$2" ] && help 
  25 set -e # exit on error 
  28 orig_name
=$
( basename    "$orig_link" ) 
  29 orig_dest
=$
( readlink 
-f "$orig_link" ) 
  32 ln -r -s "$orig_dest" "$dest_dir/$orig_name"