Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* Showing context and grep
@ 1997-09-26  4:00 KATHY.WEST
  1997-09-30  4:00 ` Phil Farrell
  0 siblings, 1 reply; 2+ messages in thread
From: KATHY.WEST @ 1997-09-26  4:00 UTC (permalink / raw)



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.

I have looked through the man pages and can't figure out a way to do
this.  Does anyone know a way?  BTW, I don't have to use grep; any DEC
UNIX tool will do.

Thanks in advance for you help,

mp



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Showing context and grep
  1997-09-26  4:00 Showing context and grep KATHY.WEST
@ 1997-09-30  4:00 ` Phil Farrell
  0 siblings, 0 replies; 2+ messages in thread
From: Phil Farrell @ 1997-09-30  4:00 UTC (permalink / raw)
  To: KATHY.WEST@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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1997-09-30  4:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-09-26  4:00 Showing context and grep KATHY.WEST
1997-09-30  4:00 ` Phil Farrell

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