I am able to replace the string AllowOverride None with AllowOverride All in the block , but I am only able to print the block of text that matches.
How do I print the text before and after the match?
awk '
/<Directory \/var\/www\/>/, /<\/Directory>/ {
sub(/AllowOverride None/,"AllowOverride All")
print
}
' /etc/apache2/sites-available/default
You can just perform the substitution without printing in the first clause, and then add a second clause to print every line. Like this:
I did a quickie test of this, and I believe it will work.