当前目录下搜索:find .  -name "*.*" | xargs grep "password=*" --color=always  

备注:这个命令会输出当前目录下不存在匹配字符串的的子目录

完美的当前目录下搜索字符串命令:grep "password=*" -R -n --color=always

查找目录:find /(查找范围) -name '查找关键字' -type d
查找文件:find /(查找范围) -name 查找关键字 -print

find . -type f -size +500M

-type 指定查找类型为文件  -size 指定文件大小 +表示大于500M
 <指定条件>: 
所要搜索的文件的特征。
[1]根据文件名查找
-name    按照文件名查找 
-iname   根据文件名查找,但是不区分大小写
-prune    不在当前指定的目录中查找 
-depth    在查找文件时,首先查找当前目录中的文件,然后再在其子目录中查找

逐层搜索文件夹以及子文件关键字

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


匹配多条件查找:可以采用or条件操作

find /var/log \( -name "rsync_yum_2016*" -o -name "rsync_yum_2017*" \)  备注:注意\(后面的空格,还有\)前面的空格

或者find /var/log -name "rsync_yum_2016*" -o -name "rsync_yum_2017*"



模糊匹配查找关键字:

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