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