title: .sh output to .txt file - what am I doing wrong?
body: <p>I am running Windows 10 and am trying to save the error output of a test.sh file to a text file.
  So I created the test.sh file and wrote an unkown command in it (i.e. "blablubb").</p>
  
  <p>After that I open the terminal (cmd.exe), switch to the directory and type <code>test.sh 2&gt;&gt; log.txt</code>.</p>
  
  <p>Another window opens with "/usr/bin/bash --login -i \test.sh" in the title bar, shows me "bash: blablubb: command not found" and then closes immediately.</p>
  
  <p>I want to save that output because the bash-window just opens for a split second. Every google search brings me to websites talking about redirecting the output and that Stream2 ist STDERR and therefore I should use <code>test.sh 2&gt;&gt; log.txt</code> or something smiliar that takes care of the STDERR stream.</p>
  
  <p>If I try the same with a test.sh file and the content:</p>
  
  <p><code>#!/bin/bash
  echo hi there</code></p>
  
  <p>I get the output in the briefly open bash-window:</p>
  
  <p><code>bash: #!/bin/bash: No such file or directory
  hi there</code></p>
  
  <p>But the log.txt file is empty.</p>
  
  <p>If I only have <code>echo hi there</code>in the test.sh file I get <code>bash: echo: command not found</code> in the bash-window.
  The log.txt also empty.</p>
  
  <p>If I type the following directly in the terminal, the output is written in the log.txt:</p>
  
  <p><code>echo hi &gt; log.txt 2&gt;&amp;1</code></p>
  
  <p>If I type directly in the terminal:</p>
  
  <p><code>echdo hi &gt; log.txt 2&gt;&amp;1</code></p>
  
  <p>I get 'Der Befehl "echdo" ist entweder falsch geschrieben oder konnte nicht gefunden werden.' in the log.txt file.</p>
  
  <p>So I guess the redirecting of the output works fine until I use test.sh.
  I know that .sh files are something from the unix world and that the problem might lie there but I don't know why I can not redirect the output briefly shown in the bash-console to a text file.</p>