I have a file which have several sections, I have to change the values of all parameters in section [Test2].
Input:
[Test_1]
abc=123
def=456
.
.
.
so on
[Test_2]
abc=123
def=456
.
.
.
so on
[Test_3]
abc=123
def=456
.
.
.
so on
Expected output:
[Test_1]
abc=123
def=456
.
.
.
so on
[Test_2]
abc=111
def=222
.
.
.
so on
[Test_3]
abc=123
def=456
.
.
.
so on
I tried this:
sed "/\[Test_2\]/{n;s/^\(abc=\).*/\1$val1/';}" input > output.new && mv output.new input
sed "/\[Test_2\]/{n;s/^\(def=\).*/\1$val2/';}" input > output.new && mv output.new input
Where $val1=111 and $val2=222.
But I am not getting expected output. Can anyone help on this?