linxu find 命令 搜索字符串

http://blog.csdn.net/beijihukk/article/details/76584991

一直记不住  

find .|xargs grep -ri "要查找的字符串"



http://blog.csdn.net/zj0910/article/details/32375801

当前目录下搜索:find .  -name "*.*" | xargs grep "password=*" --color=always  
全量目录搜索:find  / -name "*.*" | xargs grep -i "password=*" |grep -v "password=*" --color=always  
逐层搜索文件夹以及子文件关键字

find / -type f | egrep "\.log\$"| xargs grep -n -E -H "*assword=*" | egrep ":[ ]*[_a-zA-Z]" | sed "s:/\*.*\*/::g;s://.*::g" | egrep "*assword=*" --color=always


不同文件类型并列搜索:find / -type f | egrep "\.log\$|\.sh\$|\.xml\$" | xargs grep  -i "password" --color=always

精确查找关键字:
find / -type f -name "*.log"  | xargs grep -i "password" --color=always  
find / -type f -name "*.log"  | xargs grep -i "password" --color=auto
find / -type f | egrep "\.log\$" | xargs grep -i "password" --color=always


模糊匹配查找关键字:


1)模糊匹配文件类型  与  模糊匹配 关键字
1、【搜索慢】按字节块字符来匹配搜索
find / -type f -name "*.*"  | xargs grep -R -i -E '*@storage*|*assword*'  --color=always


2.【搜索快】高精度 精确性搜索
find / -type f | egrep "\.log\$" | xargs grep -R -i -E '*@storage*|*assword*'  --color=always
find / -type f | egrep "\.log\$|\.sh\$" | xargs grep -R -i -E  "*@storage*|*assword*" --color=always

2)指定文件类型  与  模糊匹配 关键字
find / -type f -name "*.log"  | xargs grep -n -E -H "*@storage*" --color=always
find / -type f | egrep "\.log\$" | xargs grep -R -i -E '*@storage*'  --color=always
find / -type f | egrep "*.log" |xargs grep -n -E -H  '*storage*'  --color=always
find / -type f | egrep "\.log\$"| xargs grep -n -E -H "*@storage*" | egrep ":[ ]*[_a-zA-Z]" | sed "s:/\*.*\*/::g;s://.*::g" | egrep "*@storage*|*assword*" --color=always

目录下搜索:grep -niR 'Admin@storage' /  --color=always
cat *.* | grep -n -E -H '*@storage*|*assword*'  --color=always
cat *.* | grep -R -i -E '*@storage|*assword' --color=always

在多/多个不同文件类型中查找
1)指定多个个文件类型使用grep,egrep并列过滤
find / -type f | egrep "\.sql\$|\.log\$|\.cfg\$|\.cpp\$|\.h\$|\.hpp\$|\.htm\$|\.html\$|\.inc\$|\.java\$|\.js\$|\.jsp\$|\.pl\$|\.properties\$|\.sh\$|\.xml\$"| xargs grep -n -E -H "pass|password" | egrep ":[ ]*[_a-zA-Z]" | sed "s:/\*.*\*/::g;s://.*::g" | egrep "pass|password"  >  check_Security.log 

2)指定单个文件类型 使用grep,egrep并列过滤
find / -type f | egrep egrep "\.log\$" | xargs grep -n -E -H "*storage" | egrep ":[ ]*[_a-zA-Z]" | sed "s:/\*.*\*/::g;s://.*::g" | egrep "*storage" --color=always


  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值