转自:https://blog.csdn.net/wangli61289/article/details/53895192
某个文件夹下的创建时间超过3分钟的文件删除。
#!/bin/bash dir=`ls /root/20160705/` DIR_PATH="/root/20160705/" for fi in $dir do FILE_NAME=${DIR_PATH}${fi} echo $FILE_NAME a=`stat -c %Y $FILE_NAME` b=`date +%s` if [ $[ $b - $a ] -gt 120 ];then echo "delete file:$FILE_NAME" rm -rf $FILE_NAME fi done echo "done"