Fix symbolic links after version change

view story

http://unix.stackexchange.com – Say I have a symbolic link to a file, which has its version in its name. (The file is actually a jar file) Now say, that the version changes, i.e the old file I linked to is deleted and a new one is generated with a different version in its name. How do I generate a new link with the new name pointing to the newly generated jar file and delete the old link in a bash script. What I have working this far is something like that: cd $THE_FOLDER_OF_BROKEN_LINKS find . -type l -exec test ! -e {} \; -print0 | xargs -0 -i readlink "{}" | sed -r "s#(.*/).*\.jar#\1#g" Which gets me, for each of the (HowTos)