2
rated 0 times
[
2]
[
0]
/ answers: 1 / hits: 21368
/ 2 Years ago, mon, april 4, 2022, 10:47:27
I have a bash script for installing a web server on my Ubuntu server.
I'd like, in the /etc/apache2/apache2.conf, to replace
#ServerRoot "/etc/apache2"
#
by
#ServerRoot "/etc/apache2"
ServerName localhost
#
If I do
sed -i 's|#ServerRoot "/etc/apache2"|#ServerRoot "/etc/apache2"
ServerName localhost|' /etc/apache2/apache2.conf
it's working, but I'd like to include the blank line and the # after the #ServerRoot to avoid adding twice ServerName if the script is executed twice.
I tried
sed -i 's|#ServerRoot "/etc/apache2"
#|#ServerRoot "/etc/apache2"
ServerName localhost
#|' /etc/apache2/apache2.conf
But it's not working.
More From » bash