I'm trying to uncomment a 4 line section in an (nginx config) file. Using sed
. I first tried with grep and the regexp seems to be correct:
$ grep ^#.*bny /etc/nginx/sites-enabled/default
# location /bny {
However when I try with sed to delete the #
at the start of the line it fails:
$ sudo sed -i '/^#.*bny/,+3 s/^#+//' /etc/nginx/sites-enabled/default
$ grep ^#.*bny /etc/nginx/sites-enabled/default
# location /bny {
I think I use the same tactics for commenting the section with sed and that works just fine:
sudo sed -i '/bny/,+3 s/^/#/' /etc/nginx/sites-enabled/default
Even double commenting is no problem. What am I doing wrong with the uncommenting?