mv a file without breaking a symlink to that file

You are on the right track, I don't think there is an easier way than the sequence you describe.

Steps 3 and 4 are a little confusing. If you want to re-target existing links you keeping the same name you can use ln -f to overwrite existing files. If you want the name of your links to also change to reflect the new target name, your sequence is correct.


For your situation:

# change target of a symbolic link
# -------------
# ln -s, --symbolic    make symbolic links instead of hard links
# ln -f, --force       remove existing destination files
#
# Setup: make junk.link to  file junk
  echo hello > ~/junk
  ln -s ~/junk ~/junk.link;  cat ~/junk.link
#
# move file and point the link to it.
  org="$(readlink ~/junk.link)"
  new="$org".moved
  mv "$org" "$new"
  ln -s -f "$new" "$new".link  # '-s' for a soft link