I'm trying to set some numeric values in my nginx.conf file. I'm calling sed from the RUN command in my Dockerfile.
Specifically I'm wanting to change what is currently:
worker_processes 4;
To:
worker_processes 1;
Regular expressions are powerful, but $*(&(*Y hard to make work.
I found this, which works.
sed -i '/access_log/s|/[^;]\+|/dev/stdout|' /etc/nginx/nginx.conf
But modified to this and it doesn't.
sed -i '/worker_processes/s|/[^;]\+|1|' /etc/nginx/nginx.conf
If someone could explain how the expression works the first time and not the second and how to make it work, that'd be great.
How SED Works. In the syntax, you only need to provide a suitable “new string” name that you want to be placed with the “old string”. Of course, the old string name needs to be entered as well. Then, provide the file name in the place of “file_name” from where the old string will be found and replaced.
Note that sed doesn't alter the original file, so all changes will show in the output, but the original file remains the same for each command we successively run.
This worked for me in the end.
sed -i 's/^worker_processes.*/worker_processes 1;/' /etc/nginx/nginx.conf
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