Find Trick: Print The Broken Symlinks

This find oneliner displays all the broken links in the current directory. By adding xargs rm, you can delete all the broken links found.

Watch Free Movies

Find all the broken links:
$ find . -type l -exec sh -c "file -b {} | grep -q ^broken" \; -print

Delete all the broken links:
$ find . -type l -exec sh -c "file -b {} | grep -q ^broken" \; -print | xargs rm

 

Scroll to Top