linux find命令詳解


單個字符“?”,多個字符"*"
”-a “並且,“ -o ” 或,“  –not”否
find -name *history //查找當前目錄及子目錄下所有以history結尾的文件
find -name mysql* //查找當前目錄及子目錄下所有以mysql開頭的文件
find -name mysql* -o -name *history //查找以mysql開頭或history結尾的文件

沒有搜索目錄,默認是當前目錄下,可以在find 后面加上目錄名
find /data -name ding

-amin n   查找系統中N分鍾之前訪問的文件
-atime n  查找系統中n*24小時之前訪問的文件
-cmin n   查找系統中N分鍾之前被改變文件狀態的文件
-ctime n  查找系統中n*24小時之前被改變文件狀態的文件
-mmin n   查找系統中N分鍾之前被改變文件數據的文件
-mtime n  查找系統中n*24小時之前被改變文件數據的文件
find -mmin -10 //查找最近10分鍾修改過的文件
find /tmp -atime -1 // 查找一天內在/tmp目錄下訪問過的文件

find /tmp -prem 755 // 查找該/tep權限是755的文件

find -size +100M //搜索大於100M的文件
find -size +100M -ls         //搜索大於100M的文件,並顯示詳情


find -type d 是目錄,f 是文件

--exec 讓我們用find這個命令去做一件事情,
find /tmp/ding.html -exec mv {} {}.`date +%F` \;
對找到的文件加上年-月-日;ding.html.2018-04-25
刪除30天之前的文件命令
find /tmp -atime +30 -exec rm -rf {} \;



免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM