Linux find查詢最近更新訪問過的檔案

2021-08-26 19:16:11 字數 972 閱讀 6184

linux中find常見用法示例·

find path -option [-print] [-exec -ok command]{} \;

#-print 將查詢到的檔案輸出到標準輸出

#-exec command {} \; 將查到的檔案執行command操作,{} 和 \;之間有空格

#-ok 和-exec相同,只不過在操作前要詢使用者

-mtime -n +n

按照檔案的更改時間來查詢檔案,-n表示檔案更改時間距現在n天以內,+

n表示檔案更改時間距現在n天以前

find /home -mtime -2

在/home下查最近兩天內改動過的檔案

find /home -atime -1

查1天之內被訪問過的檔案

find /home -mmin +60

在/home下查60分鐘前改動過的檔案

find /home -amin +30

查最近30分鐘前被訪問過的檔案

find /home -newer tmp.txt

在/home下查更新時間比tmp.txt近的檔案或目錄

find /home -anewer tmp.txt 在/home下查訪問時間比tmp.txt近的檔案或目錄

find /home -used -2

列出檔案或目錄被改動過之後,在2日內被訪問過的檔案或目錄

示例:檢視比指定檔案新的所有的檔案,步驟如下:

1.建立乙個基準時間檔案

//比如建立乙個「建立時間」為2023年01月01日00時00分的檔案-- time_file

//時間格式為 [[cc]yy]mmddhhmm[.ss]

# touch -t 201001010000 oknow

2.檢視比oknow更新的檔案

find . -newer oknow

參考:linux下find命令例項

linux 刪除指定時間前的檔案

Linux find查詢最近更新訪問過的檔案

linux中find常見用法示例 find path option print exec ok command print 將查詢到的檔案輸出到標準輸出 exec command 將查到的檔案執行command操作,和 之間有空格 ok 和 exec相同,只不過在操作前要詢使用者 mtime n n...

linux find相關 (持續更新中)

find name txt find name test 指的是當前路徑,查詢全域性的話把.換成 find type f name txt exec rm f find cmin 60 查詢過去乙個小時內修改的檔案 find atime 50 修改時間在最近50天訪問的檔案 find mtime 5...

Linux find 查詢檔案

在日誌資料夾下判斷是否有web伺服器的日誌資料夾,寫了個指令碼 bin bash cd wls annuity acc for sys in cat wiiserver name list.txt do find logs sys name sys xargs echo en n 123.txt f...