From: Frank Terbeck <ft@bewatermyfriend.de>
To: zsh-users@sunsite.dk
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 [thread overview]
Message-ID: <20060901151517.GC18634@fsst.voodoo.lan> (raw)
In-Reply-To: <Xns9831A29573C98zzappergmailcom@80.91.229.5>
zzapper <david@tvis.co.uk>:
> 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
next prev parent reply other threads:[~2006-09-02 7:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-01 14:59 zzapper
2006-09-01 15:15 ` John Eikenberry
2006-09-02 13:59 ` zzapper
2006-09-01 15:15 ` Frank Terbeck [this message]
2006-09-02 18:41 ` zzapper
2006-09-01 15:27 ` Roman Cheplyaka
2006-09-01 15:36 ` zzapper
2006-09-01 15:28 ` Chris Johnson
2006-09-01 16:52 ` Marc Chantreux
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060901151517.GC18634@fsst.voodoo.lan \
--to=ft@bewatermyfriend.de \
--cc=zsh-users@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).