title: Append file contents to the bottom of existing file in Bash
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/5586293/shell-script-to-append-text-to-each-file">Shell script to append text to each file?</a><br>
    <a href="https://stackoverflow.com/questions/6207573/how-to-append-output-to-the-end-of-text-file-in-shell-script">How to append output to the end of text file in SHELL Script?</a>  </p>
  </blockquote>
  
  
  
  <p>I'm trying to work out the best way to insert api details into a pre-existing config. I thought about using <code>sed</code> to insert the contents of the api text file to the bottom of the config.inc file. I've started the script but it doesn't work and it wipes the file. </p>
  
  <pre><code>#!/bin/bash
  
  CONFIG=/home/user/config.inc
  API=/home/user/api.txt
  
  sed -e "\$a $API" &gt; $CONFIG
  </code></pre>
  
  <p>What am I doing wrong?</p>