Fandom

How To Wiki

How to find broken symbolic links

1,795pages on
this wiki
Add New Page
Talk0 Share

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

To display a list of the broken links, replacing ${directory} with the desired root directory Edit

find /path/to/search -xtype l
as explained at http://ynform.org/w/Pub/UnixSymbolicLink
for f in $(find /path/to/search -type l); do if [ ! -e "$f" ]; then echo "$f"; fi; done

To display a list of the broken links, with where they link to Edit

find -xtype l -exec ls -l {} \;
find /usr/local/bin -type l | while read f; do if [ ! -e "$f" ]; then ls -l "$f"; fi; done
all one line, if there are broken links it will display them with ls -l

To REMOVE the broken links Edit

find /path/to/search -xtype l -delete
find -L /path/to/search-type l -delete
find /path/do/search -type l | while read f; do if [ ! -e "$f" ]; then rm -f "$f"; fi; done

None of these methods will detect cyclic links. For information on that, see:

http://ynform.org/w/Pub/FindCommandDetectUnixCyclicSymbolicLink

Also on Fandom

Random Wiki