#!/bin/bash
date=$(date +%Y%m%d)ago_date=$(date +%Y%m%d -d '2 day ago')old_file=`ls | grep $ago_date`echo $old_filehosts_path=`ls /home/fanshikui/mysqlback170218 /home/fanshikui/backup_default_netcfg.sh /home/fanshikui/"test" `#路径自行修改,改完可以直接用hosts_back=/root/"$date"hosts.back#backfile=$date"$back".bak#cat $hosts_path >$hosts_backfor back in $hosts_pathdoif [ -f $back ]; thencat $back >"$back"$date.bakfi#backfile="$back".bakbackfile="$back"$date.bakmv $backfile /root/echo $backfiledone#rm -rf `$old_file`#echo $hosts_pathfor deloldfile in $old_filedoif [ -f $deloldfile ];thenrm -rf $deloldfilefidone