Wednesday, June 24, 2009

How to Find Dangling Symlinks

Sometimes, you need to find all symbolic links which point to a non-existant target (aka, a dangling symlink).  Well, I found[1] an easy way to dig them up...
find -L . -type l
And the best part is, it's portable (well, it works on RHEL5, Ubuntu 6.06, and Mac OS X 10.5).  Another way[2] to do it with GNU find is...
find . -follow -lname '*'