SUMMARY: grep-ing for a next line information

From: William Robertson <willi_robs_at_yahoo.com>
Date: Tue Oct 02 2001 - 12:41:43 EDT
I have received many different interesting solutions
to my problem. This is defintitely the best mailing
list on the web... Oh well, this is the only mailing
list I am subscribed to.

Many special thanks go to:

Jed Dobson		Michael Auria
Steve Mickeler		John Hughes
Sanjiv K.Bhatia		John Leadeham
Grant, Dave		Dennis Martens
Junmin Liu		Dan Lowe
Scott McCool		ed.rolison
David Meissner		Ernst-Gunar Ortlepp
todd.a.fiedler		Christian Iseli
Lumpkin, Buddy		Christopher L. Barnard
Andy Bach		Julian, John C
Heilke, Rainer		Nelson, Lincoln

sorry if I missed anyone.

Almost all solutions worked for me but I chose the
suggestion that came from John Leadeham: 
sed -n '/The number of e-mails .*ted is/{;n;p;}'
filename

Sorry I cant list all other solutions but here are
some of them:

nawk '/rejected/{x=NR+1; print x}' filename
========
grep -A 1 "The number of e-mails accepted is:" | tail
-1
========
http://www.bucks.edu/alpha-osf-managers/Mar1998-42.html
========
#!/bin/sh
for line in `grep -n print check_mail.pl | cut -d ":"
-f 1`
do
	number=`expr $line + 1`
done
========
sed -n '/e-mails/{
N
s/\n/ /
p
}' filename | awk '{print $NF}'
========
#!/usr/bin/perl -w
# grep_count.pl
while (<>) {
  if ( /^The number of e-mails (rejected|accepted)
is:/ ) {
    my $count = <>;
    printf('%s: %d", $1, $count);
  }
}   # while 
run:
perl grep_count.pl <your log file here>

========
awk '
/rejected/ {
	getline
	print $0
}' filename
========
awk '/rejected/' <filename>
Then have your script increment NR which is the
current record
number.  I think it's something like '++NR'.
Then {print $0}

====================================================
This is my original Question:
I need to write a script (sed, grep, or awk) that will
search for a specific text in a file then based on
that searched text I need to grep the next line
information only. So I am only concerned about the
next line information not the first searched text.

 
Example: The File contains the following information:
 
The number of e-mails rejected is:
75
The number of e-mails accepted is: 
450

End of file.

How do I grep "75" based on a search made to
"rejected".
 
I know I can accomplish this by grep-ing for line
number of the file but that will not work since the
file line numbers keep changing.
 
Any help is greatly appreciated.


__________________________________________________
Do You Yahoo!?
Listen to your Yahoo! Mail messages from any phone.
http://phone.yahoo.com
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Tue Oct 2 11:39:25 2001

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:42:26 EST