grep 查看前后,真好用,以前一直困惑不能查看前后,现在OK了

-A  查看匹配行后面的N行

-B 查看匹配行前面的N行

-number 查看前后的行

[root@host33 enterprise]# grep -A 3 ' message'  *app.log |more 
Please report this message and include the following information to us.<br/>
Thank you very much!</p>
<table>
<tr>
--
Please report this message and include the following information to us.<br/>
Thank you very much!</p>
<table>
<tr>

[root@host33 enterprise]# grep -B 3 ' message'  *app.log |more 
<body bgcolor="white">
<h1>502 Bad Gateway</h1>
<p>The proxy server received an invalid response from an upstream server. Sorry for the inconvenience.<br/>
Please report this message and include the following information to us.<br/>
--

[root@host33 enterprise]# grep -3 ' message'  *app.log |more 
<body bgcolor="white">
<h1>502 Bad Gateway</h1>
<p>The proxy server received an invalid response from an upstream server. Sorry for the inconvenience.<br/>
Please report this message and include the following information to us.<br/>
Thank you very much!</p>
<table>
<tr>
--

猜你喜欢

转载自curious.iteye.com/blog/2298003