Remove all invalid file links on linux

A lot of invalid links are left in the application system, use shell script to delete all invalid links
for a in `find . -type l`  
do  
    stat -L $a >/dev/null 2>/dev/null  
    if [$? -gt 0]  
    then  
      rm $ a  
    be  
done

find . –type l to find all links

stat -L If the link is invalid, the command returns 1, if it is valid, it returns 0

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324783514&siteId=291194637