How can I convert relative symbolic links to absolute symbolic links recursively in bash?
Just in case somebody looking for reverse operation: conversion from absolute links to relative:
Using python:
find . -lname "`pwd`*" -exec sh -c 'ln -snvf `python -c "from os.path import *; print relpath(\"$(readlink {})\",dirname(\"{}\"))"` {}' \;
Using only bash and sed:
find . -lname "`pwd`/*" -depth 1 -exec sh -c 'ln -snvf `echo $(readlink {}) | sed "s|\`pwd\`|.|"` {}' \;
find . -lname "`pwd`/*" -depth 2 -exec sh -c 'ln -snvf `echo $(readlink {}) | sed "s|\`pwd\`|..|"` {}' \;
find . -lname "`pwd`/*" -depth 3 -exec sh -c 'ln -snvf `echo $(readlink {}) | sed "s|\`pwd\`|../..|"` {}' \;
etc....
This would convert all absolute links in the subdirectories to a relative ones.
ln -sf "$(readlink -f "$link")" "$link"