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