操作actions:
-delete:
-exec command: 執(zhí)行多個命令,直到遇到帶;的命令
-exec comand {} \; :
-execdir command:
-execdir comand {} \; :只執(zhí)行查找的文件的當(dāng)前目錄
-fprint:
-prune:修剪,只顯示文件所所指向的目錄:
find的運算符:
(expr):
!:非
not:
expr1 expr2:并且
expr1 -a expr:并且
expr1 -and expr2:并且
expr1 -o expr2:或者
expr1 -or expr2:或者
三種標(biāo)準(zhǔn)格式:POSIX,GNU,BSD
環(huán)境變量:
LANG:
LC_ALL:
PATH:
POSIXLY_CORRECT: 設(shè)置了這個環(huán)境變量,那么 -perm +zzz這樣的模式會出錯
Determines the block size used by -ls and -fls. If POSIXLY_CORRECT is set, blocks are units of 512 bytes. Other‐
wise they are units of 1024 bytes.
When POSIXLY_CORRECT is not set, -perm +zzz is treated just like -perm /zzz if +zzz is not a valid symbolic mode.
When POSIXLY_CORRECT is set, such constructs are treated as an error.
常見使用例子:
找到文件名為core的文件,并刪除:
find /tmp -name core -type f -print | xargs /bin/rm -f
如果文件或目錄含有單引號、雙引號、換行符,以下的find也能找到:
find /tmp -name core -type f -print0 | xargs -0 /bin/rm -f
找到當(dāng)前目錄下面的文件,并執(zhí)行file命令:
find . -type f -exec file '{}' \;
或:find . -type f -exec file {} \;
遍歷跟目錄,查找setuid的文件和目錄并保存到/root/suid.txt,查找大于100M的文件并保存到/root/big.txt,%#m=文件權(quán)限前面加特殊標(biāo)記位,%u =UID,%p=文件名稱,%s=文件大。
find / \( -perm -4000 -fprintf /root/suid.txt '%#m %u %p\n' \) \
\( -size +100M -fprintf /root/big.txt '%-10s %p\n' \)
查找家目錄下面在最近24小時內(nèi)修改的文件:
find $HOME -mtime 0
尋找sbin目錄下面可執(zhí)行但是不可讀的文件,!是非的意思,使用轉(zhuǎn)義字符\進(jìn)行轉(zhuǎn)義:
find /sbin /usr/sbin -executable \! -readable -print
精確匹配:
find . -perm 664
find . -perm -664 至少包含644權(quán)限
find . -perm /222 ugo的權(quán)限位只要滿足一個條件即可
find . -perm /220
find . -perm /u+w,g+w
find . -perm /u=w,g=w
find . -perm -444 -perm /222 ! -perm /111
find . -perm -a+r -perm /a+w ! -perm /a+x
find repo/ -exec test -d {}/.svn \; -or \
-exec test -d {}/.git \; -or -exec test -d {}/CVS \; \
-print -prune
2015職稱計算機考試書PowerPoint2007中 .. 定價:¥45 優(yōu)惠價:¥42 更多書籍 | |
2015年全國職稱計算機考試教材(2007模 .. 定價:¥225 優(yōu)惠價:¥213 更多書籍 |