一个删除无效链接的脚本
来源:互联网 发布:21天学通c语言高清pdf 编辑:程序博客网 时间:2024/05/17 23:59
一个删除无效链接的脚本 #!/bin/sh
# When lpath is /, it can delete all null links existing in your system INTERACTIVELY!!!
#
# Written by home_king<home_king@163.com>
#
prompthelp()
{
echo ========================================
echo 'Delete symbolic links with null target.'
echo 'usage:dellink [-e] [-o] [PATH]'
echo ' -f:EXPERT mode,no prompt.WARNNING!!!'
echo ' -c:Just apply to current directory.'
echo ' -h:Print this help.'
echo ' Without PATH, we set it ".".'
echo ========================================
}
delflag=""
promptdel()
{
read -p 'WARNNING!!!Without PROMPT!!!Continue?[y/n]' delflag
case $delflag in
y ) return 0;;
n ) exit 1;;
* ) promptdel
esac
}
while getopts ":fch" opt; do
case $opt in
f ) INTERACTIVE="f"
promptdel;;
c ) DEPTH="maxdepth 1";;
h ) prompthelp
exit 0;;
? ) echo "Invalid Option!"
prompthelp
exit 1
esac
done
shift $(($OPTIND - 1))
lpath=$1
[ $# -gt 1 ] && prompthelp && exit 1
if [ -d $1 ]; then
linklist=$(find $1 -${DEPTH:-"depth"} -type l |xargs)
for i in $linklist; do
[ ! -f $i ] && rm -${INTERACTIVE:-"i"} $i
done
else
echo "PATH is not a directory!"
prompthelp
fi
# When lpath is /, it can delete all null links existing in your system INTERACTIVELY!!!
#
# Written by home_king<home_king@163.com>
#
prompthelp()
{
echo ========================================
echo 'Delete symbolic links with null target.'
echo 'usage:dellink [-e] [-o] [PATH]'
echo ' -f:EXPERT mode,no prompt.WARNNING!!!'
echo ' -c:Just apply to current directory.'
echo ' -h:Print this help.'
echo ' Without PATH, we set it ".".'
echo ========================================
}
delflag=""
promptdel()
{
read -p 'WARNNING!!!Without PROMPT!!!Continue?[y/n]' delflag
case $delflag in
y ) return 0;;
n ) exit 1;;
* ) promptdel
esac
}
while getopts ":fch" opt; do
case $opt in
f ) INTERACTIVE="f"
promptdel;;
c ) DEPTH="maxdepth 1";;
h ) prompthelp
exit 0;;
? ) echo "Invalid Option!"
prompthelp
exit 1
esac
done
shift $(($OPTIND - 1))
lpath=$1
[ $# -gt 1 ] && prompthelp && exit 1
if [ -d $1 ]; then
linklist=$(find $1 -${DEPTH:-"depth"} -type l |xargs)
for i in $linklist; do
[ ! -f $i ] && rm -${INTERACTIVE:-"i"} $i
done
else
echo "PATH is not a directory!"
prompthelp
fi
- 一个删除无效链接的脚本
- 批量删除的一个脚本
- linux上删除所有的无效文件链接
- [脚本]Unity3d 链接到一个网页的脚本
- 一个批量删除文件的脚本
- 如何删除在Excel中存在的无效的链接呢
- QWebView隐藏时使用代码点击网页上的一个链接或按钮无效。
- 删除无效的sqlserver注册
- uboot的链接脚本
- 软链接的删除
- 递归查找无效的符号链接
- 删除TCOStream的脚本
- 怎样处理网站的有效链接和无效链接
- cron运行php脚本无效的问题
- Linux的链接脚本分析
- linux 链接脚本的编写
- Linux下的链接脚本 .
- Linux下的链接脚本 . .
- Java泛型九诫
- Ubuntu桌面中文网正式上线![00原创]
- 关于JavaFX
- linux启动后如何直接进入字符界面及如何返回图形界面
- 推荐:Java开发者必去的技术网站
- 一个删除无效链接的脚本
- 年轻人如何买房?
- QQ 2006 正式版协议变动情况分析
- Learn From LaMothe
- 文本文件中读取中文乱码的问题
- 学期内表情的变化--兔斯基版 (搞笑)
- QQ协议调试器 QQDebugger
- 单身的七夕
- 七夕的无奈