title: Bash script: only echo line to ~/.bash_profile once if the line doesn't yet exist
body: <p>I wrote a <a href="http://www.mattdipasquale.com/blog/2010/05/30/instructions-how-to-install-git-from-source-on-mac-os-x-10-6-snow-leopard-intel-x86-32-bit/" rel="nofollow">bash git-install script</a>. Toward the end, I do:</p>
  
  <pre><code>echo "Edit ~/.bash_profile to load ~/.git-completioin.bash on Terminal launch"
  echo "source ~/.git-completion.bash" &gt;&gt; ~/.bash_profile
  </code></pre>
  
  <p>The problem is, if you run the script more than once, you end up appending this line multiple times to ~/.bash_profile. How do I use bash scripting with <code>grep</code> or <code>sed</code> (or another option you may recommend) to only add the line if it doesn't yet exist in the file. Also, I want to add the line to <code>~/.profile</code> if that file exists and <code>~/.bash_profile</code> doesn't exist, otherwise just add it to <code>~/.bash_profile</code>.</p>