Find broken symlinks and delete them

Look for the broken link, and  list them:

#find -L /path -type l

Delete broken link

#find -L /path -type l -delete

To delete with confirmation do:

#find -L /path -type l -exec rm -i {} +

L flag follows symlinks, so the -type l test only returns true if the link can’t be followed, or is a symlink to another broken symlink.

Leave a Reply

Your email address will not be published. Required fields are marked *