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 {} /;