shell tip : identify broken symlinks
November 29th, 2008 by Stephane KattoorIf you need to identify broken symlinks, you can do the following :
find -L . -type l
The -L options instructs find to follow symlinks when possible. Hence no “working symlink” will ever get returned as the targets won’t match -type l (meaning “file is a symlink”).
On the other hand, find will not be able to follow broken symlinks, so the information will be taken from the symlink itself and not from the non-existent or otherwise unreachable target. The -type l will then be a match and the broken symlink filename will be returned.

Case solved
Thanks to the “Ferg’s Gaff” blog (especially the comments) for showing the way !
Tagged with: broken symlinks • linux • shell • symlinks • tips • unix


















November 30th, 2008 at 4:03
cool. Glad that was useful!
Cheers
Ferg