title: bash script: echo >> returns error "No such file or directory"
body: <p>Why isn't working this code?</p>
  
  <pre><code>#!/bin/bash
  
  test="~/.test"
  
  function fn_append () {
  
      echo "check vars: $1  ···  ${1} ··· $2"
      echo "check comm: echo \"$2\" &gt;&gt; $1"
          #this returns "No such file or directory"
      echo $2 &gt;&gt; $1
      echo $2 &gt;&gt; ${1}
      echo $2 &gt;&gt; "$1"
          #this creates file named $1
      echo $2 &gt;&gt; '$1'
          #this works (but it isn't enough)
      echo $2 &gt;&gt; ~/.test
          #this is the command Im trying to create.
      #echo "alias ll='ls -lstra'" &gt;&gt; ~/.test
  }
  
  fn_append ${test} "alias ll='ls -lstra'"
  </code></pre>
  
  <p>Executing outputs this:</p>
  
  <pre><code>check vars: ~/.test  ···  ~/.test ··· alias ll='ls -lstra'
  check comm: echo "alias ll='ls -lstra'" &gt;&gt; ~/.test
  ./test.sh: line 9: ~/.test: No such file or directory
  ./test.sh: line 10: ~/.test: No such file or directory
  ./test.sh: line 11: ~/.test: No such file or directory
  </code></pre>
  
  <p>The file does exist (though even if it doesn't the script should work anyway) and I have permissions. The command works on terminal and hardcoded on the script. What fails is something related to the "$1".</p>
  
  <p>P.D: I know there are other ways to append a file. I've been using them for now, but still I would like to fix this code or at least to know why it isn't working.</p>