Replace multiple patterns together with retaining the text in between

Hi Team

I have the following text in one of the file

j1738-abc-system_id(in.value1)-2838 G566-deF-system_id(in.value2)-7489

I want to remove system_id(...) combination completely The output should look like this

j1738-abc-in.value1-2838 G566-deF-in.value2-7489

Any help is appreciated Thanks

try

 
 sed -e 's/-system_id(//g' -e 's/)//g'
 
1 Like

that works, but say in this case

j1738-abc-system_id(substr(in.value1))-2838 G566-deF-system_id(in.value2)-7489

i am getting

j1738-abc-substr(in.value1-2838 G566-deF-in.value2-7489

its trying to replace both the "))"

How about this?

 
 sed -e 's/-system_id//g' -e 's/)//g'  -e 's/(//g'
 
1 Like

Would this help:

sed -e 's/system_id(\([^)]*\))/\1/g' file
j1738-abc-substr(in.value1)-2838 G566-deF-in.value2-7489
1 Like