腳本功能:清理$1給定目錄下無效的符號鏈接,如果$1爲空則清理當前目錄下無效的符號鏈接
#!/bin/bash if [ ! -d $1 ];then echo -e "\033[31mError, $1 Is not a directory" exit 3 fi declare -i Sum=0 for Links in $(find $1 -type l);do stat -L $Links > /dev/null 2> /dev/null if [ $? -gt 0 ];then rm $Links && echo -e "\033[31m$Time delete $Links\033[m" let Sum++ fi done echo echo -e "\033[1mdelete $Sum link"