Reputation: 2585
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?
Upvotes: 0
Views: 266
Reputation: 195059
see this example:
kent$ echo 'TheParameter="TheValue"'|sed 's/\(TheParameter="\).*/\1newValue"/'
TheParameter="newValue"
Upvotes: 2
Reputation: 56059
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.
Upvotes: 1