[CentOS] grep

Tue Aug 28 14:13:00 UTC 2007
Steve Huff <shuff at vecna.org>

On Aug 28, 2007, at 10:05 AM, Scott McClanahan wrote:

> Not a CentOS specific question, although I am running grep on  
> CentOS 4.3
> but how would you grep out a series of lines in a file starting at a
> specific point.  For instance, if I have a file named foo and I  
> want to
> grep out the next 5 lines after the first and only instance of the
> string "bar" how could I pull that off?  Thanks so much.

for the line matching "bar" and the next five lines after it:

$ grep -A 5 bar foo

if you don't want the line matching "bar":

$ grep -A 5 bar foo | tail -5

-steve

--
If this were played upon a stage now, I could condemn it as an  
improbable fiction. - Fabian, Twelfth Night, III,v