You need to capture the text inside the parentheses and repeat it in the replacement output. This requires regex backslash referencing.
sed -r 's/\((.*)\)/xxxxxx\1/g' TMP4
However, the result might still be less-than-desired, as .*
is greedy, and depending on the input might grab more than you want. If you'd give us some more details about how the input text is actually formatted, we might be able to narrow it down more.
@markush; I don't think that will satisfy his requirements, as it will put the x's both before and after the string, when he seems to want it to be only before.