人生不设限

导航

while read line 查找指定日期的文件夹

#!/bin/bash
dir=/root/tmp
targetdir=/root/tmp/tmp
filenametxt=/tmp/filename.txt
commandtxt=/tmp/command.txt
echo "">${filenametxt}
echo "">${commandtxt}

find ${dir} -name "mydumper*" -mtime +60  -type f -exec ls {} \;>${filenametxt}
cat ${filenametxt}|awk -F'_' '{print $2}'|while read line
do
week_day=`date --date=${line} +%u`
if [ ${week_day} != 5 ];then
echo "备份文件的生成日期是,星期"${week_day}
filename=`cat ${filenametxt}|grep $line`
cmd="mv "${filename}" "${targetdir} 
echo "生成移动命令:"${cmd}
echo $cmd>>${commandtxt}
fi 
done

 

posted on 2017-12-15 18:46  风的_理想  阅读(506)  评论(0编辑  收藏  举报