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 '*'
[1] http://linux.derkeiler.com/Mailing-Lists/Debian/2006-06/msg01907.html
[2] http://mail.milwaukeelug.org/wws/arc/mlug-list/2007-03/msg00243.html

2 comments: