linux系统删除满足特定条件的文件

删除文件夹中文件名含有“badcase”的文件:

  1. 首先找到这些文件
  2. 然后加删除命令
  3. 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 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章