In the Riak app.config file there is a section that looks like this:
%% JMX Config
{riak_jmx, [
{enabled, false}
]},
I want to substitute it for this:
%% JMX Config
{riak_jmx, [
{enabled, true}
]},
Yeah, pretty trivial, but I've wanted to be able to do this for ages, multi-line text replacement. I'd like to use AWK or Sed to perform the operation.
(It's worth mentioning that I'm on OSX so I don't have the fancy GNU versions of those programs).
The closest I've gotten with either is the following, which don't really work properly...
sed '/{riak_jmx/,/]},/{ c\
\{riak_jmx, [\
\{enabled, false\}
; }' ./app.config
And:
awk '/{riak_jmx/,/]},/{ if($0 ~ "{enabled, false}") {
print "{enabled, true}" }
else {
print $0
} }1' < ./app.config
Which doesn't work either. Both these commands print the old, and new version of the block.
Any ideas?
try using sed's s command:
sed '/{riak_jmx/,/]},/{ s/enabled, false/enabled, true/;}' ./app.config
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With