I have a simple config file that looks a bit like this:
[sectionA]
url = value1
username = value2
password = value3
[sectionC]
url = value1
username = value2
password = value3
[sectionB]
url = value1
username = value2
password = value3
And I want to replace the username for SectionB to be valueX
without touching SectionA's or SectionC's username.
I've tried some variations on sed
, but as far as I've managed to fathom it seems to operate on individual lines.
How do I do the equivalent of
- Search for StringA (in this case
[SectionB]
) - Find the next occurrence of StringB (
username = value2
) - Replace with StringC ('username = valueX`)
sed
:awk
: