新学的一个grep语法

By | 2017年2月24日

[root@www ~]# grep [-A] [-B] [–color=auto] ‘搜寻字符串’ filename
选项不参数:
-A :后面可加数字,为 after 癿意思,除了列出该行外,后续癿 n 行也列出杢;
-B :后面可加数字,为 befer 癿意思,除了列出该行外,前面癿 n 行也列出杢;
–color=auto 可将正确癿那个撷叏数据列出颜色

例如:

[root@node1 logs]# more catalina.out | grep -n -A5 -B4 –color=auto error
54-INFO: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
55-Feb 21, 2017 6:57:56 PM org.apache.catalina.core.StandardContext startInternal
56-SEVERE: One or more listeners failed to start. Full details will be found in the appropriate container log file
57-Feb 21, 2017 6:57:56 PM org.apache.catalina.core.StandardContext startInternal
58:SEVERE: Context [/payment] startup failed due to previous errors
59-Feb 21, 2017 6:57:56 PM org.apache.catalina.startup.HostConfig deployDirectory
60-INFO: Deployment of web application directory /home/caoqinghua/tomcat_8027_payment/webapps/payment has finished in 3,121 ms
61-Feb 21, 2017 6:57:56 PM org.apache.coyote.AbstractProtocol start
62-INFO: Starting ProtocolHandler [“http-bio-8027”]
63-Feb 21, 2017 6:57:56 PM org.apache.coyote.AbstractProtocol start

4519-log4j:ERROR Could not instantiate appender named “stdout”.
4520-Feb 22, 2017 3:55:05 PM org.apache.catalina.core.StandardContext startInternal
4521-SEVERE: One or more listeners failed to start. Full details will be found in the appropriate container log file
4522-Feb 22, 2017 3:55:05 PM org.apache.catalina.core.StandardContext startInternal
4523:SEVERE: Context [/payment] startup failed due to previous errors
4524-Feb 22, 2017 3:55:05 PM org.apache.catalina.startup.HostConfig deployWAR
4525-INFO: Deployment of web application archive /home/caoqinghua/tomcat_8027_payment/webapps/payment.war has finished in 3,259 ms
4526-Feb 22, 2017 3:55:05 PM org.apache.coyote.AbstractProtocol start
4527-INFO: Starting ProtocolHandler [“http-bio-8027”]
4528-Feb 22, 2017 3:55:05 PM org.apache.coyote.AbstractProtocol start

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注