0

I have this pair in my configuration file:

TheParameter="TheValue"

I am trying to replace the TheValue from a bash script like, with no luck.

sed 's/TheParameter="(.*)"/TheParameter="NewValue"/' /etc/my.conf 

Can anyone suggest the correct way?

0

2 Answers 2

2

see this example:

kent$  echo 'TheParameter="TheValue"'|sed 's/\(TheParameter="\).*/\1newValue"/'
TheParameter="newValue"
Sign up to request clarification or add additional context in comments.

Comments

1

sed, by default, uses basic REs, in which () are not special (don't capture or group). You either need to escape them (\(.*\)), use the -E flag (extended REs), or drop them entirely.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.