Well, grep
would additionally not allow you to make modifications, so that utility is out of the picture from the start.
Using GNU sed
instead:
$ sed '/^client_encryption_options:/,+1s/enabled:.*/enabled: true/' file
This will find the line starting with the string client_encryption_options:
and will apply a substitution to it and the following line. The substitution will replace the string enabled:
and everything following it on the same line with enabled: true
.
The substitution will be applied to both lines, but since the pattern enabled:.*
isn't found on the first line, it will remain unchanged. The second line will be changed unconditionally (regardless of the text after enabled:
).