Advertisement

06.30.2008 at 10:48AM PDT, ID: 23527706
[x]
Attachment Details

finding rows in a file

Asked by stummj in Shell Scripting, Regular Expressions

Tags: egrep

I have a large unix text file that is structured like this:

START
REF dqdqd
akjdljakldjalkdjalkjd
dkjlajdlakjdlakjdaskl
LINE dkjdlakjdaljd
LINE dajdlajdlajdldjd
TOTAL akjhadkhadkahd
kfdljakljdadlja
END
START
REF ddadasd
dkjlajdlakjdlakjdaskl
kfdljakljdadlja
END
START
REF
LINE dajdlajdlajdldjd
END

I need to somehow, within a korn shell script, extract the REF line, the LINE line(s) and the TOTAL line (if present) but ONLY if the LINE line(s) is present between a START and END

So in this example, my output would be

REF dqdqd
LINE dkjdlakjdaljd
LINE dajdlajdlajdldjd
TOTAL akjhadkhadkahd
REF
LINE dajdlajdlajdldjd

Can anyone help?Start Free Trial
[+][-]06.30.2008 at 10:59AM PDT, ID: 21901397

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.30.2008 at 11:23AM PDT, ID: 21901616

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.30.2008 at 12:03PM PDT, ID: 21902016

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Shell Scripting, Regular Expressions
Tags: egrep
Sign Up Now!
Solution Provided By: ozo
Participating Experts: 1
Solution Grade: A
 
 
[+][-]06.30.2008 at 12:19PM PDT, ID: 21902191

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628