Problem with sed string substitution

Hi,

heres my problem:

echo "aaaa(aaaa(aaa" | sed 's/a.*(//g'

gives aaa

but it should give aaaa(aaa

.*( should find any string to the appearance of (, but it finds any string to the last appearance, any idea why, and how to do this?

and what if the string ist
aaaa(aaaa(aaaa(aaa and i want to replace it to the second appearance

this is just a small example, but I hope it's clear what I mean

cheers

funksen

I am not sure if I understood what you want, but maybe this is can help:

echo "aaaa(aaaa(aaa" | sed 's/a[^(]*(//1'
aaaa(aaa

thanks alot, that is exactly what I'm looking for

the clue ist [^(]*