1. 程式人生 > >linux下查詢特定時間段內生成的檔案

linux下查詢特定時間段內生成的檔案

如下,查詢9點到11點生成的檔案,不包括9和11,即查詢10點生成的檔案

方法1:

ls -l 20120816bak|awk '{split($7,hour,":");if(hour[1]>9 &&hour[1]<11) print}'
方法2:先touch 2個時間段的時間標記
touch -t 08160900 starttime
touch -t 08161100 endtime

然後

find ./20120816bak -type f -newer starttime -a ! -newer endtime -exec ls -l {} \;

方法3:如果檔名含有時間點,則可採用字元集合或者括號擴充套件
比如查詢10點到23點所有的檔案

ls  -l   GSC_ZX_14[0-3]_20120816[1-2][0-9]* 


查詢 12點到22點的所有檔案
ls  -l   GSC_ZX_14[0-3]_20120816{12,13,14,15,16,17,18,19,20,21,22}*