title: How to use bash tee to redirect stdout and stderr to a file from script which has screen in the hash bang
body: <p>I have a script which needs to run in screen so I included </p>
  
  <pre><code>#!/usr/bin/screen /bin/bash
  </code></pre>
  
  <p>as the hash bang and it works great. The only problem is that when the script crashes I don't know what happened, the output is lost and all I know is that screen terminated.</p>
  
  <p>My script is interactive so I need to see stdout and stderr in the terminal and I also want stdout and stderr logged in case it crashed.</p>
  
  <p>I tried to run the script like </p>
  
  <pre><code>./test-screen-in-bash.sh 2&gt;&amp;1|tee test1.log
  </code></pre>
  
  <p>which results in an empty test1.log file</p>
  
  <p>Can somebody please explain what am I doing wrong.</p>