您现在的位置是:网站首页> 编程资料编程资料
linux删除无效链接文件脚本分享_linux shell_
                    
                
                2023-05-26
                370人已围观
            
简介 linux删除无效链接文件脚本分享_linux shell_
Linux终端下执行,用于删除无效的链接文件。
#!/bin/sh
usage()
{
    echo "RemoveBroken 0.1, a shell script to remove broken link files."
    echo "License: MIT, (c) chenzhiqiang"
    echo "Usage:"
    echo "  $0 --help           print this help."
    echo "  $0 --path PATH      broken links under this PATH will be removed."
    echo "  $0 --stdin          read PATHs from stdin."
    echo "  $0                  same as $0 --stdin."
}
fromStdin()
{
    while [ 1==1 ]
    do
        read
        [ "$REPLY" != "" ] || exit 0
        [ ! -L $REPLY -o -e $REPLY ] || unlink $REPLY
    done
}
fromPath()
{
    find $2 | $0 --stdin
}
if [ $# = 0 ]
then
    usage
    fromStdin
    exit 0
fi
case $1 in
--stdin)
    fromStdin
--path)
    find $2 | $0 --stdin
--help)
    usage
*)
    echo "RemoveBroken: unknown usage."
    usage
esac
相关内容
- nginx日志切割脚本分享_linux shell_
 - Shell编程之Shell变量学习总结_linux shell_
 - 使用curl递归下载软件脚本分享_linux shell_
 - mysql源码安装脚本分享_linux shell_
 - 从apnic提取ip信息脚本分享_linux shell_
 - 实现批量linux格式化硬盘和挂载硬盘脚本分享_linux shell_
 - 自动生成linux网卡配置脚本分享_linux shell_
 - Linux Shell脚本编程的注意事项_linux shell_
 - Shell字符串截取的详细方法_linux shell_
 - csh,tcsh,bash,sh等shell的区别_linux shell_
 
                                
                                                        
                                
                                                        
                                
                                                        
    