Skip to content

Instantly share code, notes, and snippets.

@coldpour
Created February 13, 2017 17:49
Show Gist options
  • Select an option

  • Save coldpour/727fb2d1ef9932ba09e6c9c34c30527b to your computer and use it in GitHub Desktop.

Select an option

Save coldpour/727fb2d1ef9932ba09e6c9c34c30527b to your computer and use it in GitHub Desktop.
move symlinks from one user to another
repairLinks() { for l in `ls -la | grep '\->' | grep "${1}" | awk '{print $9 "->" $11}'`; do t=`echo ${l%->*}`; o=`echo ${l#*->}`; s=`echo $o | sed "s/${1}/${2}/"`; echo "moving link ${t} from ${o} to ${s}"; rm -f $t; ln -s $s $t; done }
# example usage
# -------------
# repairLinks mholm holmi09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment