Re: block-based editing
- From: Loki Harfagr <loki@xxxxxxxxxxxxxxxxxx>
- Date: Wed, 24 May 2006 13:59:14 +0200
Le Wed, 24 May 2006 03:55:56 -0700, aryzhov a écrit :
Hello All,
This must be a simple question, but since I am an "inline AWK
programmer",
figuring it out may take hours if not days for me.
Or I could split and join using an ugly shell script.
That's a last resort, but maybe there's a better idea?
I've got this input::
*****
whatever
... good pattern ...
whatever
*****
whatever
whatever
... good pattern ...
whatever
*****
... bad pattern ...
whatever
*****
whatever
..good pattern
whatever
*******
i.e. multiple blocks of text separated with ****, with eilter good
of bad pattern in them (one per block only). I want to get rid
of entire blocks with bad pattern, along with either preceeding
or following delimiter ****
If you can have the choice for your separators I'd advise you to
change the very special '*' to something more casual :-)
If so, saying your separator is '+++++' (five plus), this would do :
$ gawk '/good pattern/' RS=+++++
If you're stuck with the star, or non gawk, let's hope it'll be
indifferent to how many there are on the separator line, if so, use :
$ awk '/good pattern/' RS=*
If these don't work, please show sample results on your system (and
describe the sys/awk you have), we'll may have to use circular buffers
or else ;-)
.
- Follow-Ups:
- Re: block-based editing
- From: aryzhov
- Re: block-based editing
- References:
- block-based editing
- From: aryzhov
- block-based editing
- Prev by Date: how to join lines
- Next by Date: Re: how to join lines
- Previous by thread: block-based editing
- Next by thread: Re: block-based editing
- Index(es):