1. 程式人生 > >Linux 查詢某時間段內的所有檔案

Linux 查詢某時間段內的所有檔案

1.如果是精確到天

如:在20-50天內修改過的檔案

 find ./ -mtime +20 -a -mtime -50 -type f


2.精確到時分秒

如:在2015年5月10日內的檔案

方法一:

touch -t 201505100000 t_start;touch -t 201505102359.59 t_end;find . -type f -newer t_start ! -newer t_end | xargs ls -l | grep -v "t_start\|t_end";rm -f t_start;rm -f t_end;

先建立兩個時間結點檔案;查詢時間結點範圍內的檔案(-newer   f1 !f2               #查更改時間比f1新但比f2舊的檔案

);過濾檔案;刪除臨時檔案t_start,t_end;

方法二:

find  -type f \( -newermt '2015-05-10 00:00'  -a -not -newermt '2015-05-10 23:59' \)

(     注意在-newermt前面有(  ,在末尾有)   , csdn編輯反斜槓大括號不顯示???)