>I wanted to append into a system file, that needed sudo permission:
sudo cat Automation/other_files/hhtp_cont >> /etc/apache2/httpd.conf
>but I got the following error
x.sh: 1: cannot create /etc/apache2/httpd.conf: Permission denied
>But since sudo can do everything, then why?
>The possible explanation for this is that (>>) works before sudo, so it is not run with the sudo power and hence gives the above stated error
>It can be easily sorted out and can be done as following easily.
>One alternative way is to wrap the whole command in another bash command and then run it with sudo.
>It Works.. :-)
>Try the solution below.
sudo bash -c "cat Automation/other_files/hhtp_cont >> /etc/apache2/httpd.conf"
sudo cat Automation/other_files/hhtp_cont >> /etc/apache2/httpd.conf
>but I got the following error
x.sh: 1: cannot create /etc/apache2/httpd.conf: Permission denied
>But since sudo can do everything, then why?
>The possible explanation for this is that (>>) works before sudo, so it is not run with the sudo power and hence gives the above stated error
>It can be easily sorted out and can be done as following easily.
>One alternative way is to wrap the whole command in another bash command and then run it with sudo.
>It Works.. :-)
>Try the solution below.
sudo bash -c "cat Automation/other_files/hhtp_cont >> /etc/apache2/httpd.conf"