Linux下grep的基本过滤技巧
显示包含Orcl-Extract-Serv:63的字符串
tail -f /opt/apache/apache-tomcat-6.0.29/logs/catalina.out |grep Orcl-Extract-Serv:63
白名单过滤策略
显示包含Orcl-Extract-Serv:63或Orcl-Extract-Serv:62的字符串
tail -f /opt/apache/apache-tomcat-6.0.29/logs/catalina.out |grep -E "Orcl-Extract-Serv:63|Orcl-Extract-Serv:62"
黑名单过滤策略
过滤掉包含Orcl-Extract-Serv:或Orcl-Load-Serv:的字符串
错误写法
tail -f /opt/apache/apache-tomcat-6.0.29/logs/catalina.out |grep -v "Orcl-Extract-Serv:"|"Orcl-Load-Serv:"
正确写法
tail -f /opt/apache/apache-tomcat-6.0.29/logs/catalina.out |grep -v "Orcl-Extract-Serv:\|Orcl-Load-Serv:"
tail -f /opt/apache/apache-tomcat-6.0.29/logs/catalina.out |grep -v "Orcl-Extract-Serv:"|grep -v "Orcl-Load-Serv:"
Author: lioncode
CMP: JTSEC-RD
Date: 2016-05-07 23:34
Project: jtsec_one-way_dbsync
Version: v2.0.0
注:文章部分内容或来自互联网,由本人借鉴整理而成,每一篇笔记可能就有您的一份功劳,在此感谢!
================ lioncode ======================== lioncode ========================== lioncode =====================
参考文章:
http://www.blogjava.net/zhyiwww/archive/2009/01/21/252170.html
grep -v 'aaaa\|bbbb' file
2.grep查找多个数字的文件:
-r 递归,-E:正则 -l:只显示文件名
[email protected]:~/a# 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