更新时间:2023-12-04 21:02:34
find
是此类任务的常用工具:
find
is the common tool for this kind of task :
find ./my_dir -mtime +10 -type f -delete
说明
./my_dir
您的目录(替换为您自己的)-mtime +10
超过 10 天-type f
仅文件-delete
并不奇怪.在执行整个命令之前删除它以测试您的 find
过滤器
./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 your find
filter before executing the whole command
并注意 ./my_dir
的存在以避免意外!
And take care that ./my_dir
exists to avoid bad surprises !