Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

records selection after a pattern..

28 views
Skip to first unread message

varsha

unread,
Apr 22, 2013, 9:48:45 PM4/22/13
to

Hi,

I am extracting records from a print file after meeting a certain pattern(including the pattern record).

Here the records which are starting with space and number and the immediate record of the pattern.

1 actmodule 15:12:15
logged in
work finished
12 plmodule 11:11:16
corrections taken
logged out

----
----

awk 'c&&c--; (this is EdMorton's earlier solution)
/^ [0-9]/||/^ [09]/||/^ [0-9]/{printf"%s",$0;c=1}'

I am trying to make the pattern met records into a single line.

1 actmodule 15:12:15 logged in
12 plmodule 11:11:16 corrections taken

But when I am trying to extract two records after the pattern the second record
after the pattern is not appearing in single line.

awk 'c&&c--; (this is EdMorton's earlier solution)
/^ [0-9]/||/^ [09]/||/^ [0-9]/{printf"%s",$0;c=2}'

How to get all the three lines into a single line?

Loki Harfagr

unread,
Apr 23, 2013, 4:16:00 AM4/23/13
to
Mon, 22 Apr 2013 18:48:45 -0700, varsha did cat :
Personnally I'd go for a two-pass process, first one to ease up your input,
second pass to set up some action on the records, e-g
(one big line, migh be b0rtched by some clients):

$ awk --re-interval '/^[[:blank:]]+[[:digit:]]+[[:blank:]]+[^[:blank:]]+/{print ORS};1' yourfile | awk '$1=$1' RS= FS='\n'
0 new messages