2

I am trying to append some config to another file like this

sudo cat config/add-this.yml >> ~/docker-compose.yml

via shell script. But trying this gives me a Permission denied error.

How can I simply append some content to another file?

user3142695
  • 1,599

1 Answers1

1

The problem is that the shell performs redirections before the command is executed.

In this case. unless the permissions of the file into which data is to be added allow appending, a permission denied error results.

You can circumvent this by doing:

sudo sh -c 'cat config/add-this.yml >> ~/docker-compose.yml'
JRFerguson
  • 14,740