脚本功能:清理$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"