Parse and delete lines efficiently

Hi

I have a set of options in the form of key value in a file. Need to find a particular value of 'a' and delete all lines till the next 'a' keyword .

Ex :

a bbb
c ddd
e fff
g hhh

a sss
c ggg
e xxx
f sss

a ddd
d sss
r sss
g hhh

and so forth

Here 'a' keyword is present in each stanza. I need to parse to find a particular value of 'a' (let's say 'sss') and from there, delete all lines till the next 'a' keyword.

Thanks

Always, give the input and the expected output and the condition.
It will be easier if you give the ouput.

Input

a bbb
c ddd
e fff
g hhh

a sss
c ggg
e xxx
f sss

a ddd
d sss
r sss
g hhh

Output

a bbb
c ddd
e fff
g hhh

a ddd
d sss
r sss
g hhh

Try this

awk  'NR%2==1{print}' RS="\n\n" ORS="\n\n" filename

Ranjith - Can you please explain your command below...

Let's assume I found the line with "a sss" using grep... all I now need to do is start deleting lines till I find the next keyword "a ..." (... can be any value)

Hope that gives better picture.

It's kind of
(while nextkeyword != 'a')
{
delete all lines inbetween
}

Hi,

Sorry misunderstood your requirement. Below script will delete the data from line starting with "a sss" untill the line starting with "a".

awk '$0~"^a" {flag=1} $0~"^a sss" {flag=0} flag==1'  filename

Regards,

Ranjith