天天看點

find指令的參數

find [path] [option] [action]

與時間有關的參數:-mtime -ctime -atime

n n為數字 n天之前

-n 在n天之内 包含n天

+n 在n天之前 不含n天

-newer file 列出比file還要新的檔案

有關使用者群組名的參數

-uid n: n為數字 這個數字是使用者帳号的id 在/etc/passwd

-gid n: n為數字 這個數字是使用者組名的id 在/etc/group

-user name: name 為使用者賬戶

-group name: 使用者組名

-nouser: 尋找檔案的所有者不存在 /etc/passwd

-nogroup: 尋找檔案的所有使用者組不在/etc/group

-depth:以第幾層路徑為機關查找

maxdepth 1-?     mindepth 1-?

與檔案權限及名稱有關的參數

-name filename: 查找檔案名為filename的

-size [+-]SIZE 查找比size大或者小的檔案,c 代表byte k代表1024bytes  +size 50k

-type TYPE 查找檔案類型 正規檔案f/裝置檔案b,c/目錄d/連接配接檔案l/socket s/fifo p等屬性

-perm mode 查找檔案權限剛好等于mode檔案

-perm -mode 查找全部包括mode的檔案

-perm +mode 查找包含任一mode權限的檔案

例: find / -perm +7000 查找檔案suid+sgid+sbit

-exec command:command為其他指令 -exec後邊可以在接其他指令來處理結果

-print 将結果列印到螢幕

find / -perm +7000 -exec ls -l {} \;

{}表示find找到的内容 會被仿制到{}中

-exec 一直到\; 是關鍵字 代表find額外指令開始-exec 到結束\; 在中間的ls -l就是額外指令

因為;在bash下有特殊意義 是以要用反斜杠來轉意

find /etc -name '*http*'

本文轉自歲月丶傾城部落格51CTO部落格,原文連結http://blog.51cto.com/alca0126/1342639如需轉載請自行聯系原作者

laihuadongcto