title: redirect COPY of stdout to log file from within bash script itself
body: <p>I know how to <strong>redirect stdout</strong> to a file:</p>
  
  <pre><code>exec &gt; foo.log
  echo test
  </code></pre>
  
  <p>this will put the 'test' into the foo.log file.</p>
  
  <p>Now I want to <strong>redirect the output into the log file AND keep it on stdout</strong></p>
  
  <p>i.e. it can be done trivially from outside the script:</p>
  
  <pre><code>script | tee foo.log
  </code></pre>
  
  <p>but I want to do declare it within the script itself</p>
  
  <p>I tried</p>
  
  <pre><code>exec | tee foo.log
  </code></pre>
  
  <p>but it didn't work.</p>