Basic filtering techniques for grep under Linux
Display a string containing orcl-extract-serv:63
Tail-f/opt/apache/apache-tomcat-6.0.29/logs/catalina.out |grep orcl-extract-serv:63
Whitelist filtering policy
Display a string containing orcl-extract-serv:63 or 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 "
Blacklist filtering policy
Filter out strings that contain orcl-extract-serv: or Orcl-load-serv:
Wrong wording
Tail-f/opt/apache/apache-tomcat-6.0.29/logs/catalina.out |grep-v "Orcl-extract-serv:" | " Orcl-load-serv: "
Correct wording
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
Note: The article part of the content or from the Internet, from my collation, each note may have your credit, in this thanks!
================ lioncode ======================== lioncode ========================== lioncode ==================== =
Reference article:
Http://www.blogjava.net/zhyiwww/archive/2009/01/21/252170.html
GREP uses multiple query criteria--or[[email protected] ~]# grep ' Usrquota\|Grpquota '/etc/fstab
label=/1/ext3 Defaults,usrquota,grpquota 1 1
/dev/hda10/mnt/test1 ext3 Defaults,grpquota 1 3
[email protected] ~]#
The above method is found on the Internet. The live color section can achieve multiple conditionsorrelational queries.
Other methods:
"1" uses multiple-e parameters
such as:
Netstat-an | grep-e "established| WAIT "
Note:
Netstat-an | grep-e est-e WAIT
using multiple-e parameters in parallel can be implemented or conditional
"2" Using extensions
such as:
Netstat-an | grep- e "established| WAIT "
Note:
the-E is capitalized here, and the matching criteria must be quoted
|----------------------------------------------------------------------------------------|
Copyright @zhyiwww Copyright Notice
Reference Please specify source http://www.blogjava.net/zhyiwww
|----------------------------------------------------------------------------------------|
GREP-V also exclude multiple files or directories grep is a powerful file Search command in Linux, he can use regular expressions to search for text and print out the matching lines, let's look at the tip of the iceberg.1. To exclude AAAA and exclude bbbb, use the following code:
Grep-v ' aaaa\|bbbb ' file
2.grep find multiple numbers of files:
-R recursion,-E: Regular-L: Show only file names
[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
Tail-f/opt/apache/apache-tomcat-6.0.29/logs/catalina.out |grep-v "orcl-extract-serv:\| Orcl-load-serv: "
Basic filtering techniques for grep under Linux