Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: Phil Farrell <farrell@pangea.stanford.edu>
To: "KATHY.WEST@US.GASES.BOC.COM" <KATHY.WEST@US.GASES.BOC.COM>
Subject: Re: Showing context and grep
Date: 1997/09/30	[thread overview]
Message-ID: <343144AA.7336@pangea.stanford.edu> (raw)
In-Reply-To: 342BB790.AB3@US.GASES.BOC.COM


KATHY.WEST@US.GASES.BOC.COM wrote:
> 
> Hi all,
> 
> I am using grep to search many large log files for different events.
> For each line that's matched, I would like to show the matched line and
> the line that immediately follows it.

You could to this with a small awk program.  For example, if you are 
looking for the regular expression "regexp", and want to see the following
line as well, this awk program would do the job:

     awk '/regexp/ {print;c=1;next}; c == 1 {print;c=0}'  inputfiles

This could be extended to print additional lines of following context by
incrementing the variable "c" and then testing against some limit before
resetting to 0.

-- 
Phil Farrell, Computer Systems Manager
Stanford University School of Earth Sciences
farrell@pangea.stanford.edu



      reply	other threads:[~1997-09-30  4:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-09-26  4:00 Showing context and grep KATHY.WEST
1997-09-30  4:00 ` Phil Farrell [this message]
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox