- the portable way
1 find /path/to/search -type l -exec test ! -e {} \; -print
but gnu findutils are also pretty portable, and support -xtype
1 find /path/to/search -xtype l- if the link was not broken, it would have resolved to a type other than l
- by default
1 find -L /path/to/search -type l- -L means to dereference symbolic links, but since a broken link can't be dereferenced, it's simply of type "link"
not entirely equivalent to find /path/to/search -xtype l, because it will expand the search into directories that are the target of found symlinks
None of these methods detect cyclic symbolic links. See use GNU Find to detect cyclic symbolic links for a method of doing that.
- the portable way