删除文件夹中文件名含有“badcase”的文件:
- 首先找到这些文件
- 然后加删除命令
- xargs代表把前面的当作后面命令的输出
find . -maxdepth 1 -regex ".*badcase.csv*"
find . -maxdepth 1 -regex ".*badcase.csv*" -exec rm -rf {} \;
或 find . -maxdepth 1 -regex ".*badcase.csv*" | xargs rm -rf
显示20分钟前的文件
find /home/prestat/bills/test -type f -mmin +20 -exec ls -l {} \;
删除20分钟前的文件
find /home/prestat/bills/test -type f -mmin +20 -exec rm {} \;
显示20天前的目录
find /home/prestat/bills/test -type d -mtime +20 -exec ls -l {} \;
删除20天前的目录
find /home/prestat/bills/test -type d -mtime +20 -exec rm {} \;在20-50天内修改过的文件
find ./ -mtime +20 -a -mtime -50 -type f
参考:https://blog.csdn.net/xueyingxue001/article/details/51498902