Linux的Find使用

來源:互聯網
上載者:User
 在目前的目錄和子目錄下尋找檔案MyCProgram.c# find . -name "MyCProgram.c"   尋找檔案且忽略大小寫# find . -iname "MyCProgram.c"  尋找不包含MyCProgram.c的檔案find . -maxdepth 1 -not -iname "MyCProgram.c"

 

 在/下3到5級子目錄中尋找passwd# find / -mindepth 3 -maxdepth 5 -name passwd

 

 尋找且執行命令find . -iname "MyCProgram.c" -exec md5sum {} \;

 

 尋找大於100m的檔案# find ~ -size +100M 尋找小於100m的檔案# find ~ -size -100M 尋找等於100m的檔案# find ~ -size 100M

 

 尋找目錄及子目錄下最大的5個檔案find . -type f -exec ls -s {} \; | sort -n -r | head -5 尋找目錄及子目錄下最小的5個檔案# find . -type f -exec ls -s {} \; | sort -n  | head -5 尋找size非零且最小的5個檔案# find . -not -empty -type f -exec ls -s {} \; | sort -n  | head -5

 

 尋找所有使用者都有寫入權限的檔案# find . -perm -g=w -type f -exec ls -l {} \;

 

 在/logs目錄中尋找更改時間在5日以前的檔案並刪除它們 $ find logs -type f -mtime +5 -exec rm { }\ ; 尋找/var/logs目錄中更改時間在7日以前的普通檔案,並在刪除之前詢問它們$ find /var/logs -type f -mtime +7 -ok rm { }\ ;

 

 可以使用某種檔案名稱模式來匹配檔案,記住要用引號將檔案名稱模式引起來,否則匹配展開後會導致find的參數混亂$ find . -name [A-Z]* -printhttp://www.linuxso.com/command/find.html

 

  在目前的目錄下尋找檔案許可權位為755的檔案,即檔案屬主可以讀、寫、執行,其他使用者可以讀、執行的檔案,可以用 $ find . -perm 755 -print 

 

http://yangdong.blog.51cto.com/2959198/546524

http://www.cnblogs.com/itech/archive/2011/04/25/2027725.html

 

 

完! 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.