I try to change Apache configuration with this:
sudo awk '/<Directory \/var\/www\/>/,/AllowOverride None/{sub("None", "All",$0)}{print}' /etc/apache2/apache2.conf | sudo tee /etc/apache2/apache2.conf > /dev/null
After this /etc/apache2/apache2.conf is empty. If I change the destination file to ~/apache2.conf for example, the output is correct.
Why?
awk '/<Directory \/var\/www\/>/,/AllowOverride None/{sub("None", "All",$0)}{print}' /etc/apache2/apache2.confoutput? You do not need sudo beforeawk. – Pilot6 Aug 20 '15 at 12:29teewill overwrite the file beforeawkgets to it. Either use a temporary file or usespongefrommoreutils. If you are using a recent version of GNU awk, it has an -i inplace argument – Thor Aug 20 '15 at 12:35sed -i– Pilot6 Aug 20 '15 at 12:37