I'm trying to edit my nginx.conf file programmatically, which contains a line like this:
which I want to look like this:
I believe the regex
^\s*access_log([^;]*); will capture the
/var/log/nginx/access.log part in a capture group, but I'm not sure how to correctly replace the capture group with sed?
echo " access_log /var/log/nginx/access.log;" | sed 's/^\s*access_log([^;]*);/\1\\\/dev\\\/stdout/'
but I'm getting the error:
sed: -e expression #1, char 45: invalid reference \1 on `s' command's RHS
if I try
sed -r then there is no error, but the output is not what I expect:
I'm trying to be smart with the capture group and whatnot and not search directly for "access_log /var/log/nginx/access.log;" in case the distribution changes the default log file location.