linux find -size参数,Linux find 常用命令
Linux?find?常用命令
(2012-10-24 11:32:52)
標(biāo)簽:
linux
shell
說明:
以下內(nèi)容,若標(biāo)注在 [ ] 中括號(hào)內(nèi)的均可省略,除非做特別說明。
但嚴(yán)格來說,若缺少 [ ] 中括號(hào)內(nèi)的內(nèi)容,在命令呈現(xiàn)的語義和返回結(jié)果上,偶爾會(huì)有些許差異。
正文:
0、使用說明
man find
找到所有關(guān)于 find 命令的說明
1、查找目錄下的內(nèi)容
1.1 所有文件
find /full/path -type f
1.2 所有文件夾
find /full/path -type d
1.3 所有 .php 文件
find /full/path [-type f] -name "*.php"
1.4 所有 .log 和 .txt 后續(xù)文件(多重選擇,注意:括號(hào)內(nèi)兩邊均帶空格)
find /full/path [-type f] \( -name "*.log" -o -name "*.txt"
\)
或者 find /full/path [-type f] -regex ".*\.\(txt\|sh\)"
1.5 所有不是 .log 和 .txt 后續(xù)的文件(否定參數(shù))
find /full/path [-type f] -not \( -name "*.log" -o -name "*.txt"
\)
或者 find /full/path [-type f] ! \( -name "*.log" -o -name "*.txt"
\)
1.6 查找大于 10KB 的日志文件
find /full/path [-type f] -size +10k
除k之外,還可以用其他文件大小單元
b—塊(512字節(jié))
c—字節(jié)
w—字(2字節(jié))
k—千字節(jié)
M—兆字節(jié)
G—吉字節(jié)
1.7 查找 24 小時(shí)內(nèi)改動(dòng)過的文件
find /full/path [-type f] -ctime -1
1.8 修改時(shí)間為7天以前的文件
find /full/path [-type f] -mtime +7
1.9 查找當(dāng)前目錄下所有的隱藏(普遍)文件(可以用 -iregex 來去除大小寫敏感)
find /full/path [-type f] -regex ".*\/\.[^/]*"
2.0 查找空文件(夾)
find /full/path -empty
2.1 查找當(dāng)前目錄中以及一級(jí)子目錄中的 php 文件
find /full/path [-type f] -name "*.php" -maxdepth 2
2.2 查找目錄下除report子目錄以外的所有文件
find /full/path -path "*report" -prune -o -print
2.3 查找權(quán)限是 777 的文件
find /full/path [-type f] -perm 777
2.4 輸出當(dāng)前目錄下所有 txt 文件的內(nèi)容
find /full/path [-type f] -name "*.txt" -exec cat {} \;
或者 find /full/path [-type f] -name "*.txt" | xargs -i cat {}
在這個(gè)命令中,{}是一個(gè)特殊的字符串,與 -exec 選項(xiàng)結(jié)合使用。
對(duì)于每一個(gè)匹配的文件,{}會(huì)被替換成相應(yīng)的文件名。
2.5 只搜索最小深度為3,最大嘗試為5的所有文件夾 ( -maxdepth參數(shù)需要放在最前面 )
find /full/path -mindepth 3 -maxdepth 5 -type d
2.6 刪除匹配的文件
find /full/path -type f -name "*.bak" -delete
分享:
喜歡
0
贈(zèng)金筆
加載中,請(qǐng)稍候......
評(píng)論加載中,請(qǐng)稍候...
發(fā)評(píng)論
登錄名: 密碼: 找回密碼 注冊(cè)記住登錄狀態(tài)
昵???稱:
評(píng)論并轉(zhuǎn)載此博文
發(fā)評(píng)論
以上網(wǎng)友發(fā)言只代表其個(gè)人觀點(diǎn),不代表新浪網(wǎng)的觀點(diǎn)或立場(chǎng)。
總結(jié)
以上是生活随笔為你收集整理的linux find -size参数,Linux find 常用命令的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux日志发送,Linux中将执行过
- 下一篇: 海尔软水机Hs13-JR(WH)u1与H