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
- X-seq: zsh-users 10656
- From: Frank Terbeck <ft@xxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: I want to list the NEXT line after a string appears in a list of files
- Date: Fri, 01 Sep 2006 17:15:17 +0200
- In-reply-to: <Xns9831A29573C98zzappergmailcom@xxxxxxxxxxx>
- Mail-followup-to: zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Operating-system: Linux 2.6.16.16 i686
- References: <Xns9831A29573C98zzappergmailcom@xxxxxxxxxxx>
zzapper <david@xxxxxxxxxx>:
> 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.
>
> Suggestions pls
[snip]
zsh% cat test0.txt
These
are
lines,
I
do
not
care
about.
but
please
display this line.
zsh% cat test1.txt
and please, oh please:
display this line, too.
not
this
one
zsh% function my_grep () {
local integer found=0
while read line ; do
(( found == 1 )) && print ${line} && return
(( found == 0 )) && [[ ${line} = *${1}* ]] && found=1
done < ${2}
}
zsh% for file in test*.txt ; do my_grep 'please' $file ; done
display this line.
display this line, too.
[snap]
Regards, Frank
Messages sorted by:
Reverse Date,
Date,
Thread,
Author