我常用的find命令

查找某种类型文件中包含特定字符的文件

find /* -type f -name "*.php" |xargs grep "rename("

find ./|xargs grep -ri "is_vip" -l

 

Linux下find一次查找多个指定文件或者排除某类文件,在 GREP 中匹配多个关键字的方法
(1)Linux下find一次查找多个指定文件:
查找a.html和b.html

find . -name "a.html" -name "b.html"
find . -regex '.*\.txt\|.*\.doc\|.*\.mp3'
find . -regex '.*\.txt\|.*\.doc\|.*\.mp3' 

./a.txt 

./a.doc 
./a.mp3

 

(2)排除某些文件类型:
排除目录下所有以html结尾的文件:

find . -type f ! -name "*.html"

./ge.bak.02.09 

./ge.html.changed.by.jack 
./a.txt 
./a.doc 
./a.mp3

 

(3)排除多种文件类型的示例:

find . -type f ! -name "*.html" -type f ! -name "*.php" -type f ! -name "*.svn-base" -type f ! -name "*.js" -type f ! -name "*.gif" -type f ! -name "*.png" -type f ! -name "*.cpp" -type f ! -name "*.h" -type f ! -name "*.o" -type f ! -name "*.jpg" -type f ! -name "*.so" -type f ! -name "*.bak" -type f ! -name "*.log"

(3)在 GREP 中匹配多个关键字的方法:

grep查找多个数字的文件:
-r 递归,-E:正则 -l:只显示文件名

grep -r -E '0341028|100081|10086|10001' * 

a.txt:100081 

b.txt:10086 
c/cc.txt:0341028 
c/cc.txt:100081 
c/cc.txt:10086 
c/cc.txt:10001 
c.txt:10001 
d.txt:0341028

 

grep -r -E -l '0341028|100081|10086|10001' * 

a.txt 

b.txt 
c/cc.txt 
c.txt 
d.txt

 

多种类型文件示例:

find . -name "*.html" -o -name "*.js"|xargs grep -r "BusiTree"

(4)查找系统大于100M的文件

find / -type f -size +1000000k 

 






本文转自秋楓博客园博客,原文链接:http://www.cnblogs.com/rwxwsblog/p/4505949.html,如需转载请自行联系原作者
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值