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?
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?
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'
chmod 777 docker-compose.yml
, right? – user3142695 Feb 10 '17 at 22:32-c
-flag do? – user3142695 Feb 10 '17 at 22:59-c
reads and executes commands from the first non-option argument command_string, and then exits. See here . – JRFerguson Feb 10 '17 at 23:23