Operating System - HP-UX
1748134 Members
3490 Online
108758 Solutions
New Discussion

Re: Please help.. a clever script needed to...

 
Donnie Darko_1
Frequent Advisor

Re: Please help.. a clever script needed to...

Thanks guys... some great tips there...

However.. the file is not as clean as I have made it appear above. It also has a lot of unwanted Junk in there, but I am only interested in the messages which appear above out of it. They are all indented in the file, eg:-

blah, blah, blah, blah........

SEVERITY Critical (Needed)
Line 1 (Needed)
Line 2 (Needed)
Line 3 (Needed)
Line 4 (Needed)

blah, blah, blah, blah,
blah, blah, blah, blah

.. u get this idea.. so I am sorry for not clarifying this initially! If anyone wants me to send them the file (4mb) or attach it here (Can I do that with 4mb!?) I will do so...

Many thanks again


Jeroen Peereboom
Honored Contributor

Re: Please help.. a clever script needed to...

Let's assume your file contains blocks of messages and the first line determines if the block must be printed or not.

Take Elmar's solution, and modify it:
awk '
/SEVERITY/ && /Critical/ { crit=1 }
/SEVERITY/ && !/Critical/ { crit=0 }
crit==1 { print }
'