shell学习笔记(十四)
$ cat week_archive.sh#!/bin/bash
#===============================================================================
# FILE: week_archive.sh
#
# DESCRIPTION: This script is used to archived file.
# CONTACT: abcd360@gmail.com
# CREATED: 20120915
# REVISION: 1.0
#===============================================================================
cd /home/zhuzhu/logs
dirname=`date +%Y%m%d '--date=7 day ago'`to`date +%Y%m%d '--date=1 day ago'`
/bin/mkdir -p/home/zhuzhu/logs/${dirname}
for i in `seq 7`
do
ls -l|egrep -v gz|egrep 'crc|txt'|egrep "`date --date "$i days ago" +"%b %d"`"|awk '{print $NF}'|while read LINE;do
mv $LINE/home/zhuzhu/logs/${dirname}
done
done
/bin/tar -zvcf $dirname.tar.gz$dirname&& rm -rf $dirname
页:
[1]