Using this file for demo purposes:
of_interest attr (
1:VALID (
1:late_lead_up xxx ar uclk reff xxx slope xxx
1:late_lead_dn xxx af uclk reff xxx slope xxx
1:early_trail_up xxx af uclk reff xxx slope xxx
1:early_trail_dn xxx ar uclk reff xxx slope xxx
1:)
1:CEXT xxx
1:CREF xxx
1:REFF xxx
1:QUALIFIED_CLOCK
)
boring attr (
2:VALID (
2:late_lead_up xxx ar uclk reff xxx slope xxx
2:late_lead_dn xxx af uclk reff xxx slope xxx
2:early_trail_up xxx af uclk reff xxx slope xxx
2:early_trail_dn xxx ar uclk reff xxx slope xxx
2:)
2:CEXT xxx
2:CREF xxx
2:REFF xxx
2:QUALIFIED_CLOCK
)
of_interest attr (
3:VALID (
3:late_lead_up xxx ar uclk reff xxx slope xxx
3:late_lead_dn xxx af uclk reff xxx slope xxx
3:early_trail_up xxx af uclk reff xxx slope xxx
3:early_trail_dn xxx ar uclk reff xxx slope xxx
3:)
3:CEXT xxx
3:CREF xxx
3:REFF xxx
3:QUALIFIED_CLOCK
)
This one-liner (split for readability):
awk '
BEGIN {s=0}
/^of_interest / {s=1}
/^)$/ {if (s==1) {print};s=0}
{if (s==1) print}'
or the minimum character version:
awk 'BEGIN{s=0}/^of_interest /{s=1}/^)$/{if(s==1){print};s=0}{if(s==1)print}'
gives you:
of_interest attr (
1:VALID (
1:late_lead_up xxx ar uclk reff xxx slope xxx
1:late_lead_dn xxx af uclk reff xxx slope xxx
1:early_trail_up xxx af uclk reff xxx slope xxx
1:early_trail_dn xxx ar uclk reff xxx slope xxx
1:)
1:CEXT xxx
1:CREF xxx
1:REFF xxx
1:QUALIFIED_CLOCK
)
of_interest attr (
3:VALID (
3:late_lead_up xxx ar uclk reff xxx slope xxx
3:late_lead_dn xxx af uclk reff xxx slope xxx
3:early_trail_up xxx af uclk reff xxx slope xxx
3:early_trail_dn xxx ar uclk reff xxx slope xxx
3:)
3:CEXT xxx
3:CREF xxx
3:REFF xxx
3:QUALIFIED_CLOCK
)
which I believe is what you were after.
It's basically a simple state machine that turns on printing when it finds the desired block start and turns it off when it finds the end of that block.
UPDATE: Here's a perl one-liner that takes care of your qualified_clock requirement. Enjoy :-)
perl -e '$s=1;while(<STDIN>){if(/^of_interest /){$s=1;$f=0;$x="";}if(($s==1)&&/QUALIFIED_CLOCK/){$f=1;}if(/^\)$/){if($s==1){$x.=$_;}if($f==1){print$x;}$s=0;next;}if($s==1){$x.=$_;}}'