当前位置: 移动技术网 > 网络运营>服务器>Linux > linux删除无效链接文件脚本分享

linux删除无效链接文件脚本分享

2017年12月12日  | 移动技术网网络运营  | 我要评论
linux终端下执行,用于删除无效的链接文件。 复制代码 代码如下:#!/bin/sh usage(){    echo "removeb

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

如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网