finding dangling symbolic links
find -L . -type l
Replace . with the directory you want to investigate, of course. Works with both GNU and (Free)BSD find. Rationale: -L makes find act on the (transitive closuse of the) target of a symlink - unless the target doesn’t exist, in which case find acts on the symlink itself. So, if the item to act on turns out to be a symlink, it has to be dangling.
Comment by roel- — Aug 15, 2007 7:43:29 PM | # - re
Nice one… gotta remember. When I ran this command I noticed my disk making nice churning sounds… seems recursive links cause quite some trouble :)
find: Symbolic link `/lib/modules/2.6.22.1/source/debian/linux-image-2.6.22.1/lib/modules/2.6.22.1/source’ is part of a loop in the directory hierarchy; we have already visited the directory to which it points.
Comment by FooBar — Aug 15, 2007 9:03:00 PM | # - re
-l? you meant:
find -L . -type l <em>[fixed, thanks]</em>
add -ls for an ls -l style listing
Comment by Deckardt — Aug 16, 2007 6:23:00 AM | # - re