使用Bash脚本批量删除PHP临时文件.out文件列表
PHP每天生成一个存有系统要删除的临时文件的.out文件列表,由bash脚本逐行通过读取.out文件(每一行代表一个待删除的文件)挨个删除,代码如下(dl.sh):
#!/bin/bash
# Shell script utility to delete file.
# You can call script as follows, to read myfile.txt:
# ./dl.sh or.txt
# Copyright (c) 2009 kokko <http://www.kokkowon.com/>
#User define Fuction(UDF)
processLine(){
line="$@" #get all args
if [ ! -f $FILE ]; then
echo "$line does not exists"
else
echo "$line"
rm -rf $line
fi
}
#echo Please enter the file name:
#read FILE
if [ ! "$1" == "" ]; then
FILE="$1"
else
echo Please enter the file name:
read FILE
fi
if [ ! -f $FILE ]; then
echo "$FILE does not exists"
exit 1
elif [ ! -r $FILE ]; then
echo "$FILE cann't read"
fi
#read $FILE using the file descriptors
BAKIFS=$IFS
IFS=$(echo -en "\n\b")
exec 3<0
exec 0<"$FILE"
while read -r line
do
processLine $line
done
exec 0<3
IFS=$BAKIFS
exit 0
执行:
kokkowon@itbeing.com [~/www]# ./dl.sh ./temp.out
结果:
./message.tmp
./ECShop_V2.7.1_UTF8_Release1228.zip
./captcha.tmp
./index.tmp
./goods_script.tmp
./region.tmp
./article.tmp
./comment.tmp
./animated_favicon.gif
./auction.tmp
./catalog.tmp
./category.tmp
./affiche.tmp
./group_buy.tmp
./search.tmp
./favicon.ico
./itbeing/Cache/776e414da1b246fca4e72f34d6e5cce9.tmp
./itbeing/Cache/e8a01c49e3bd6881d1526bce80cbcad7.tmp
./itbeing/Cache/13da2f5482df2335081ce60c3ac5828c.tmp
./itbeing/Cache/aec1e7b1c552ce75969652a157572320.tmp
./pm.tmp
./respond.tmp
./exchange.tmp
./flow.tmp
./myship.tmp
./sitemaps.tmp
./snatch.tmp
./error_log
./article_cat.tmp
相关阅读
- 萌店怎么批量管理商品 萌店批量管理商品方法
- 乐云记事怎么导出资料 乐云记事批量导出资料教程
- 微信能批量群发红包吗 微信怎么批量群发红包
- 新浪微博如何批量删除微博 微博批量删除微博方法介绍
- 快图浏览APP中的照片如何批量删除?快图浏览照片批量删除方法图文教程
- 网易公开课APP怎么批量下载课程?网易公开课批量下载课程图文教程
- 凤凰FM怎么批量下载节目 凤凰FM批量下载节目教程
- 微信不常联系的朋友怎么找不到 批量管理不常联系的朋友功能为什么没有
- 微信批量管理不常联系的朋友怎么用 批量管理不常联系的朋友入口在哪
- 微信批量管理不常联系的朋友在哪 批量管理不常联系的朋友怎么找不到
《使用Bash脚本批量删除PHP临时文件.out文件列表》由网友“像拥有”推荐。
转载请注明:http://www.modouwifi.com/jiaocheng/052010NW2021.html