Sed can handle this quite easily. It's a single "substitute" command, prefixed with an address range. I've added extra spacing for better readability:
sed -e '/^\[ABC\]$/ , /^\[.*\]$/ s/^\(value1=\).*$/\1notbla/'
Without the extra spacing, it's:
sed -e '/^\[ABC\]$/,/^\[.*\]$/s/^\(value1=\).*$/\1notbla/'
You don't really need anchored regexes, but they may be safer in some cases of unusual inputs. A slightly shorter version with unanchored regexes is:
sed -e '/\[ABC\]/,/^\[/s/^\(value1=\).*$/\1notbla/'
You asked for each flag or option to be explained, and I've got the time, so here you go. I'm explaining the final (shortest) version out of the three Sed commands listed above.
The first part of the line is an address range:
substitute command which follows the address range is only applied to lines from
In this case the start regex is
/\[ABC\]/. Square brackets are usually special characters within a regex, so we put a backslash before each to signify literal square bracket characters.
The stop regex is
/^\[/, which uses the special regex character
^ to signify the start of a line. This pattern will match any line that starts with a literal left square bracket (
substitute command is basically quite simple; the general format is
s/findregex/replacetext/. It can also have special flags placed after the final
/ to modify its behavior, but I'm not using any such flags here.
The "find regex" is
The caret (
^) matches the start of the line, as mentioned earlier, and the dollar sign (
$) matches the end of the line. So this whole pattern must match an entire line, not merely part of one.
The parentheses (
()), unlike square brackets, are non-special by default in regexes, so we put the backslashes before them to give them their special meaning. They allow parts of the matched text (the text matched by the "find regex") to be used in the replacement text. Specifically, the
\1 in the replacement text means, "The text matched within the first set of parentheses in the regex." In this case, that is always just "value1=".
The final element in the "find regex" is
.*. The dot (
.) means "any single character," and the asterisk (
*) means "any number of times (zero or more)." So the dot star (
.*) matches the entire rest of the line, after the equals sign.
"notbla" in the replacement text is just static text, nothing special about it.
To really learn Sed properly, I highly recommend the Grymoire Sed tutorial, which is free online.