Reputation: 7708
Current text
Variable length text = some string(some more text
Change to
Variable length text = some string(addition some more text
Need to add a certain text after first parenthesis in a line only after "=" character is encountered. Another condition is to ignore patterns like "= (", which essentially means you should ignore patterns with only space between "=" and "("
My Try:
sed -e "s#*=(\w\()#\1(addition#g"
Thanks in anticipation!
Upvotes: 0
Views: 611
Reputation: 65781
Tweak this for your needs:
$ echo 'Variable length text = some string(some more text' |\
sed 's/^[^=]*=[^(]*[[:alnum:]][^(]*(/&addition /'
That matches for:
=
any number of times=
(
any number of times(
any number of times(
... and substitutes it with the matched string adding ' addition'
to it.
The output is
Variable length text = some string(addition some more text
Upvotes: 1