title: Bash script: how to add a section to a config file?
body: <p>I know how to find and replace a section in a config file like this:</p>
  
  <pre><code>sudo sed -i "s/upload_max_filesize = 2M/upload_max_filesize = 3M/" /etc/php5/cgi/php.ini
  </code></pre>
  
  <p>But how do I add a whole new section to the end of the config file within the bash script?</p>
  
  <pre><code>server {
      listen      xx.xx.xx.xx:80;                # your server's public IP address
      server_name  myapp.com;                   # your domain name
      root         /usr/share/nginx/www/myapp/;  # absolute path to your WordPress installation    
  }
  </code></pre>
  
  <p>I tried this within the terminal <code>echo "server { ... }" &gt;&gt; nginx.conf</code> but I get a </p>
  
  <pre><code>-bash: nginx.conf: Permission denied
  </code></pre>
  
  <p>Not sure if this would be ok within the bash script or I would get a permission denied again...</p>