mrl22
7/18/2019 - 11:41 AM

Search and Replace Symlinks

Search and Replace Symlinks

oldpath='/home/websitedesign/public_html/lesser';
newpath='/home/lesser/public_html';
find /home/lesser/public_html -type l -execdir bash -c 'p="$(readlink "{}")"; if [ "${p:0:1}" != "/" ]; then p="$(echo "$(pwd)/$p" | sed -e "s|/\./|/|g" -e ":a" -e "s|/[^/]*/\.\./|/|" -e "t a")"; fi; if [ "${p:0:'${#oldpath}'}" == "'"$oldpath"'" ]; then ln -sf "'"$newpath"'${p:'${#oldpath}'}" "{}"; fi;' \;