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
原文地址:https://www.cnblogs.com/janehoo/p/8044485.html