Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: I want to list the NEXT line after a string appears in a list of files



On Fri, Sep 01, 2006 at 02:59:03PM +0000, zzapper wrote:
> Hi
> I want to list the NEXT line after a string appears in a list of files
> 
> eg 
> > egrep "Anecdote" m??.txt (But display next line)
> 
> I guess Sed/Awk would do this, I would probably use Perl.
--8<--
#!/usr/bin/perl
use strict;
my $regex = qr/Anecdote/;
my $print = 0;
while (<>)
{
	$print && print;
	$print = /$regex/;
}
--8<--

But, are you sure you've posted to the right place?..

-- 
Roman I. Cheplyaka



Messages sorted by: Reverse Date, Date, Thread, Author