本文介绍了删除文件使用shell脚本在Unix中早于10天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是新来的shell脚本,谁能帮助?我想从当前日期的文件夹中删除脚本回10天。这些脚本如下:
I'm new to shell scripts, can anyone help? I want to delete scripts in a folder from the current date back to 10 days. The scripts looks like:
2012.11.21.09_33_52.script 2012.11.21.09_33_56.script 2012.11.21.09_33_59.script该脚本将每10一天运行crontab,这就是为什么我需要的当前日期。
The script will run in every 10 day with Crontab, that's why I need the current date.
推荐答案找到是这类任务的常用工具:
find is the common tool for this kind of task :
find ./my_dir/* -mtime +10 -type f -delete说明
- ./ MY_DIR 目录(用自己的替换)
- -mtime +10 早于10天
- 型的F 仅文件
- -delete 毫不奇怪。删除前测试
- ./my_dir your directory (replace with your own)
- -mtime +10 older than 10 days
- -type f only files
- -delete no surprise. Remove it to test before
和照顾的 ./ MY_DIR 的存在是为了避免不良的惊喜!
And take care that ./my_dir exists to avoid bad surprises !
更多推荐
删除文件使用shell脚本在Unix中早于10天
发布评论