- ../logs/nginx:/var/log/nginx
env_file:
- ../env/uid.env
should be converted to
- ../logs/nginx:/var/log/nginx
env_file:
- ../env/nginx.env
- ../env/uid.env
There are multiple occurences of "env_file" in the file, which is why I need to match the line above as well. I'm struggling with the newline. I've tried
awk '/ env_file:/{print;print " - ../env/nginx.env";next}1' filename
this worked but it doesn't include the line above. Then I've tried this and it didn't work.
awk '/nginx\n env_file:/{print;print " - ../env/nginx.env";next}1' filename
EDIT: To clarify my issue. I cannot use the first attempt due to multiple occurrences of "env_file" in my file. I need to match an additional line (the line containing "nginx") above. And that's what I am struggling with.