日期:2014-05-16  浏览次数:20775 次

求一段Shell脚本,感谢!
-rw-r--r-- 1 nfsnobody nfsnobody  5249241368 Jun 27 03:11 DPI_100_2013062702000000.merge.done
-rw-r--r-- 1 nfsnobody nfsnobody  4319482886 Jun 27 04:11 DPI_100_2013062703000000.merge.done
-rw-r--r-- 1 nfsnobody nfsnobody  4099093541 Jun 27 05:11 DPI_100_2013062704000000.merge.done
-rw-r--r-- 1 nfsnobody nfsnobody  4229707095 Jun 27 06:11 DPI_100_2013062705000000.merge.done
-rw-r--r-- 1 nfsnobody nfsnobody  6140495830 Jun 27 07:11 DPI_100_2013062706000000.merge.done
-rw-r--r-- 1 nfsnobody nfsnobody  8336230166 Jun 27 08:12 DPI_100_2013062707000000.merge.done
-rw-r--r-- 1 nfsnobody nfsnobody 10300028031 Jun 27 09:13 DPI_100_2013062708000000.merge.done

现在盘里每小时会定时生成一个文件,文件名是有规律的。
现在我想用一段Shell脚本删除前三天的文件,参数为当天日期。

------解决方案--------------------
find . -type f -ctime +3  -exec rm -f {} \;
------解决方案--------------------
find . -type f -mtime +3 
------解决方案--------------------
 xargs rm -f
------解决方案--------------------
引用:
find . -type f -ctime +3  -exec rm -f {} \;


+++
------解决方案--------------------
#!/bin/sh
move_file_path=$1
move_file_date=$2

Usage()
{
    echo "Usage:`basename $0` move_file_date move_file_path"
}
if [ -z "$move_file_path" ]
then
    Usage
    exit
fi


参数1为路径,参数2为日期,如果不输入日期则默认为系统日期,如果不输入路径则报错退出。LZ可以按照自己的需求在shell中写好路径也可以。