SUMMARY: grep-ing for a next line information

From: William Robertson <>
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;}'

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
for line in `grep -n print | cut -d ":"
-f 1`
	number=`expr $line + 1`
sed -n '/e-mails/{
s/\n/ /
}' filename | awk '{print $NF}'
#!/usr/bin/perl -w
while (<>) {
  if ( /^The number of e-mails (rejected|accepted)
is:/ ) {
    my $count = <>;
    printf('%s: %d", $1, $count);
}   # while 
perl <your log file here>

awk '
/rejected/ {
	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:
The number of e-mails accepted is: 

End of file.

How do I grep "75" based on a search made to
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.
sunmanagers mailing list
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