Issue
I want to change all true
values to false
for all lines that contain should-log
substring, the input files contain other lines to but are not mentioned in this snippet:
logging.ap.should-log-headers = true
logging.ap.should-log-password = true
logging.api.should-log-headers = true
logging.httpbin.should-log-headers = true
logging.httpbin.should-log-password = true
logging.copy.should-log-headers = false
logging.copy.should-log-password = false
logging.test.should-log-headers = false
logging.test.should-log-password = false
logging.-test.should-log-password = true
logging.hu.should-log-headers = true
logging.madf.should-log-headers = true
logging.madf.should-log-password = true
logging.api-f-002.should-log-headers = true
logging.f.should-log-headers = true
logging.f-d.should-log-headers = true
logging.f-d.should-log-password = true
logging.copy-d.should-log-headers = false
logging.copy-d.should-log-password = false
logging.d.should-log-headers = false
logging.d.should-log-password = false
logging.e.should-log-headers = true
logging.e.should-log-password = true
what I am trying:
sed -i -E '/should-log=/{s/true/false/;}' infile
but it doesn't work, what am I doing wrong, how should I do it?
Solution
should-log=
doesn't match any of the given input lines. You could use something like should-log-
or should-log.*=
or should-log-.*=
.
Also, the {}
grouping isn't needed for single command after the address.
Answered By - Sundeep