[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Tr: Problem with grep v2.5.1
From: |
Micah Cowan |
Subject: |
Re: Tr: Problem with grep v2.5.1 |
Date: |
Fri, 18 May 2007 13:28:43 -0700 |
User-agent: |
Thunderbird 1.5.0.10 (X11/20070403) |
Simon Nieux wrote:
>> Hi,
>>
>> I use the grep utility intensively. It's a very useful software though it
>> seems there's a problem...
>>
>> wget can generate log file.
>> I wanted to display only some specific lines with 3 extra lines above them
>> from this log file.
>> Then, I wrote the following command :
>> grep -B 3 "\.\.\.[0-9]\{3\}" wget.log
>> It works very well.
>> Then, I wanted to exclude lines with the string "...200" and the 3 lines
>> above each.
>> So, I wrote the following command :
>> grep -B 3 "\.\.\.[0-9]\{3\}" wget.log | grep -v -B 3 "\.\.\.200"
>> It doesnt work at all !
>> In fact, it removes only the last line who match from the precedent response
>> but leaves the 3 lines above.
>> And surprisingly it leaves all the other lines who match...
>>
>> Is it the user who does wrong or the software ?
My understanding is that -B is meant to _include_ N lines of context
from before matches, not exclude them. What's going on is that the other
...200 lines are getting included because they are part of the -B
context of the lines that follow them and match the negative of ...200.
You might need to use awk or similar to do what you desire.
--
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer...
http://micah.cowan.name/
Re: Tr: Problem with grep v2.5.1, Andreas Schwab, 2007/05/18