title: Bash redirection with file descriptor or filename in variable
body: <p>In my script I want to be able to write to either a file or to stdout based on certain conditions.  I'm curious as to why this doesn't work in my script:</p>
  
  <pre><code>out=\&amp;1
  echo "bird" 1&gt;$out
  </code></pre>
  
  <p>I tried different combination of quotes, but I keep having a "&amp;1" file created instead of it writing to stdout.  What can I do to get this to work how I want?</p>