move links to another directory and maintain the link
if the file is not a link, do nothing
usage: ln-mv <links...> <destination>
example: ln-mv *.txt ~/Documents
#!/bin/bash# move links to another directory and maintain the link# if the file is not a link, do nothing## usage: ln-mv <links...> <destination># example: ln-mv *.txt ~/Documentsdest=${@: -1}if[-z"$dest"];thenecho"Usage: ln-mv <links...> <destination>"exit1fiif[!-d"$dest"];thenecho"Destination $dest does not exist"exit1fiforfilein"${@:1:$#-1}";doname=$(basename"$file")if[[-L"$file"]];then# move the link and maintain the linkrealpath=$(readlink--canonicalize"$file")ln-s-r"$realpath""$dest/$name"elseecho"$file is not a link. ignore"fidone