|
This might get you started.
I assume the config file and the changes file have the same format.
I also assume the changes file is a subset of the config file.
You could convert both of them to a different format.
e.g.
nawk '/\[.*\]/ { SECT=$1; next } { print SECT$0 }' configfile > tmpfile1
nawk '/\[.*\]/ { SECT=$1; next } { print SECT$0 }' changesfile > tmpfile2
Use info from tmpfile2 to make changes in tmpfile1.
When done convert tmpfile1 back to original format and use this file to replace the original config file.
running the command above on the example config file you provided would result in the following output:
tmpfile1:
[Section1]parm=value
[Section1]parm2=value
[Section1]parm3=value
[Section2]parm=value
[Section2]parm2=value
[Section2]parm3=value
Suppose your changes file looks like:
[Section1]
parm2=newvalue1
[Section2]
parm=newvalue2
Again using the command above the output would be:
tmpfile2:
[Section1]parm2=newvalue1
[Section2]parm=newvalue
Thsi puts the config and changes file in a similar format which makes it easy to make the necessary edits.
As mentioned, when the edits are done convert the format back.
|