0

I want to append the line "include /etc/nginx/tcpconf.d/*;" to the file /etc/nginx/nginx.conf.

When I did run the below command, it failed -

$ sudo cat "include /etc/nginx/tcpconf.d/*;" >> /etc/nginx/nginx.conf
-bash: /etc/nginx/nginx.conf: Permission denied

When I did the same with below bash command it is successful -

$ echo "include /etc/nginx/tcpconf.d/*;" | sudo tee --append /etc/nginx/nginx.conf
include /etc/nginx/tcpconf.d/*;

Any idea why the previous command is not working?

marked as duplicate by steeldriver, dhag, Jeff Schaller bash Apr 16 at 3:31

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    First of all, you should use echo and not cat. Secondly, the sudo in the first case runs cat and not to the whole pipeline. – Kapil Apr 16 at 2:29

Browse other questions tagged or ask your own question.