[原创]SHELL脚本删除指定的文件夹

文件夹的格式:
例如   20071201-10     20071211-20     20071221-31
        20080101-10     20080111-20     20080121-31

注:以下SHELL脚本删除以上指定的文件夹

#!/bin/bash
#==================================
#
#Author: accepting
#
#Email: accepting@126.com
#
#Data:  2008.02.02
#
#Http://accepting.sharera.com
#
        DOWNLOADS="/home/medialib/download"
#==================================
#
if [ $# -eq 0 ] ; then
        CurYear=`date   +%Y`                                 
        CurMonth=`date   +%m` 
        CurDay=`date   +%d` 
        GetYear="$CurYear" 
        GetMonth="`expr $CurMonth`" 
        GetDay="`expr $CurDay - 1`"
               
        if [ "$GetDay" -eq 10 ] ; then

                rm -rf "$DOWNLOADS$GetYear$GetMonth"01-10

                echo "$GetYear$GetMonth"01-10

        elif [ "$GetDay" -eq 20 ] ; then

                rm -rf "$DOWNLOADS$GetYear$GetMonth"11-20

                echo "$GetYear$GetMonth"11-20

        elif [ "$GetDay" -le 0 ] ; then

                GetMonth="`expr $CurMonth - 1`"

                if [ "$GetMonth" -le 0 ] ; then 

                         GetYear=`expr $CurYear - 1` 

                         GetMonth=12 
                fi

                if [ `echo "$GetMonth" | wc -m` -ne 3 ] ; then 
      
                         GetMonth=0$GetMonth 

                fi

                rm -rf "$DOWNLOADS$GetYear$GetMonth"21-30

                echo "$GetYear$GetMonth"21-31
        else

                echo --==该文件夹不存在!!!!==--

        fi

fi

posted on 2008-02-02 15:08 黑虫 阅读(1963) 评论(0)  编辑 收藏 引用 所属分类: Unix/Linux

只有注册用户登录后才能发表评论。
<2008年2月>
272829303112
3456789
10111213141516
17181920212223
2425262728291
2345678

导航

统计

常用链接

留言簿(4)

随笔分类(31)

随笔档案(31)

awmsky

搜索

最新评论

阅读排行榜

评论排行榜