- 论坛徽章:
- 1
|
shell编程的问题!
不如把年加上,让rq=`date date +%y%m%d`,这样后产生的文件的后缀一定大于先产
生的文件的后缀, 放CRON里(时间应放在文件产生后), 这样可避免跨年跨月的头痛问题
- #!/bin/ksh
- cd some_dir
- ls filename* > filelist.tmp
- file_num =` wc -l filelist.tmp`
- if [ $file_num -eq 11 ]
- then
- sed 's/.*\.//g' filelist.tmp > filelist.tmp2
- while read line
- do
- if [ $line -lt $min -o $min -eq 0 ]
- then
- last_min = $line
- fi
- done < filelist.tmp2
- else
- echo "Today's file has not created yet or there is more than 11 files in this directoy. Please check. Exiting..."
- exit 1
- fi
-
- rm filename.$last_min
- rm filelist.tmp
- rm filelist.tmp2
复制代码
未经验证 |
|