练习2:保留每月1号 每周一 7天内文件
2016-12-02 08:49
134 查看
#保留每月1号 每周一 7天内
cd $backPath
filelist=`ls $backPath/`
for f in $filelist
do
filename=$f
cutfile=`echo $filename |cut -c1-3`
cuttime=''
if [ "$cutfile" = "saf" ]; then
cuttime=`echo $filename |cut -c7-14`
elif [ "$cutfile" = "upl" ]; then
cuttime=`echo $filename |cut -c11-18`
else
echo ""
fi
chuyi=`echo $cuttime |cut -c7-8`
if [ "$chuyi" = "01" ]; then
echo $filename'chuyi======'
continue
fi
xinqi=`date -d $cuttime +%w`
if [ "$xinqi" = "1" ]; then
echo $filename'xinqiyi===='
continue
fi
sevenday=`date -d '-7 day' +%Y%m%d`
if [ "$cuttime" -gt "$sevenday" ]; then
echo $filename'serverday======'
continue
fi
rm -rf $backPath/$filename
done
cd $backPath
filelist=`ls $backPath/`
for f in $filelist
do
filename=$f
cutfile=`echo $filename |cut -c1-3`
cuttime=''
if [ "$cutfile" = "saf" ]; then
cuttime=`echo $filename |cut -c7-14`
elif [ "$cutfile" = "upl" ]; then
cuttime=`echo $filename |cut -c11-18`
else
echo ""
fi
chuyi=`echo $cuttime |cut -c7-8`
if [ "$chuyi" = "01" ]; then
echo $filename'chuyi======'
continue
fi
xinqi=`date -d $cuttime +%w`
if [ "$xinqi" = "1" ]; then
echo $filename'xinqiyi===='
continue
fi
sevenday=`date -d '-7 day' +%Y%m%d`
if [ "$cuttime" -gt "$sevenday" ]; then
echo $filename'serverday======'
continue
fi
rm -rf $backPath/$filename
done
相关文章推荐
- .Net 读取.txt文件,可以在注册中限制保留字或者BadWords过滤
- 删去一个目录下的所有文件,而保留目录结构
- Weblogic保留jsp编译后的java文件
- “WebRequestMethods.Ftp.DownloadFile不能保留文件最后修改时间”的解决方法
- 文件IO --APUE第三章原创练习代码
- 文件操作与java正则练习
- JAVA(练习)要求显示出某一个目录下的所以的文件和目录(同资源管理器显示)
- “WebRequestMethods.Ftp.DownloadFile不能保留文件最后修改时间”的解决方法
- oracle 取每月1号几点几分几秒
- Newsfan FTP1软件保留区文件列表
- 用批处理文件删除n天前的文件&&用批处理实现的保留最近的n个文件 最简单方法
- Zee之LR脚本练习之七:执行dir命令并把结果写到文件里
- 文件查找/删除 练习
- RichEdit读取Xls文件,保留表格样式
- IBatisnet中,SQL语句字符与配置文件XML保留字符冲突的区别(比如>,
- 文件相关的练习程序
- 保留weblogic 中jsp编译后生成的java文件
- 常用C头文件及其在标准C++中的保留
- 将指定目录的所有文件及文件夹copy到指定目录下,只copy 7天内创建的或是7天内修改过的
- 文件操作的思考练习