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

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

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

  2021-03-19 我要评论
想了解linux删除无效链接文件脚本讲解的相关内容吗,在本文为您仔细讲解linux删除链接文件的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:linux,链接文件,下面大家一起来学习吧。

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

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们