I need to modify a config file from a bash script, changing the values of particular settings. I need to make the change using common Linux tools (sed/awk/tr/etc.). The config file can have identically named keys in different stanzas like this:
[section1] key1=a key2=b [section2] key1=a key2=b
and the lines in each stanza can be in different order, with blank lines/comments between, etc. I've tried sed but can't match across lines (so I can't match the stanza names). Can someone suggest how to: 1. change the value associated with section1 key1 ? 2. Print to stdout the value associated with section1 key1 ?