Linux之find命令

來源:互聯網
上載者:User

Find 命令的一般形式為:find pathname -options [-print -exec -ok]

find命令的選項:

-name 按照檔案名稱尋找檔案,如:find /etc -name "host*" -print | xargs >/tmp/host.log

-perm 按照檔案許可權來尋找檔案,如:find . -perm 755 -print

-user 按照檔案屬主來尋找檔案,如:find ~ -user dave -print

-group 按照檔案所屬的組來尋找檔案,如:find /apps -group beijing -print

-nouser 尋找無有效屬主的檔案, 如:find / -nouser -print

-nogroup 尋找無有效所屬組的檔案,如:find / -nogroup -print

-size n[c] 尋找檔案長度為n塊的檔案,帶有c時表示檔案長度以位元組計,如:find /home/apache -size 100c -print

-depth 在尋找檔案時,首先尋找目前的目錄中的檔案,然後再在其子目錄中尋找

-fstype 尋找位於某一類型檔案系統中的檔案,這些檔案系統類型通常可以在設定檔/etc/fstab中找到,該設定檔中包含了本系統中有關檔案系統的資訊

-mount 在尋找檔案時不跨越檔案系統mount點,如:find . -name "*.XC" -mount -print

-follow 如果find命令遇到符號連結檔案,就跟蹤至連結所指向的檔案

-cpio 對匹配的檔案使用cpio命令,將這些檔案備份到磁帶裝置中

-newer file1 ! file2 尋找更改時間比檔案file1新但比檔案file2舊的檔案,如:假設現在的時間是23:40,希望尋找更改時間在兩個小時以內的檔案, touch -t 07212140 dstamp, find . -newer dstamp -print

-mtime -n +n 按照檔案的更改時間來尋找檔案,如: find / -mtime -5 -print (在系統根目錄下尋找更改時間在5日以內的檔案)

-type 尋找某一類型的檔案(b - 塊裝置檔案;d - 目錄;c - 字元裝置檔案;p - 管道檔案; l - 符號連結檔案f - 普通檔案),如:find /etc -type d -print -exec ls -l {} /;

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.