title: Redirect standard error output on Unix
body: <p>I created a folder, ABC. In this folder I created two files, file1 and file2. Next on the folder I set rw permissions for everybody. When I try <code>ls ABC</code> it prints:</p>
  
  <pre><code>/bin/ls: cannot access ABC/file2: Permission denied
  
  /bin/ls: cannot access ABC/file1: Permission denied
  
  file1  file2
  </code></pre>
  
  <p>I want to split this message into two parts and write to files success.txt and fail.txt. So in Bash, I tried something like:</p>
  
  <pre><code>ls ABC &gt; success.txt 2&gt; fail.txt
  </code></pre>
  
  <p>But in success.txt I have " file1 file2", but fail.txt is empty, so where are the first two lines of the message?</p>
  
  <hr>
  
  <p>Thanks Arne and shellter for your interest. So I create the folder with:</p>
  
  <pre><code>mkdir ABC
  </code></pre>
  
  <p>Next:</p>
  
  <pre><code> cd ABC
   touch file1 file2
  </code></pre>
  
  <p>Next:</p>
  
  <pre><code>cd ..
  chmod 666 ABC
  </code></pre>
  
  <p>And when I enter <code>ls ABC</code> I get:</p>
  
  <pre><code>/bin/ls: cannot access ABC/file2: Permission denied
  
  /bin/ls: cannot access ABC/file1: Permission denied
  
  file1  file2
  </code></pre>
  
  <p>But when I write an sh script like:</p>
  
  <pre><code>#!/bin/sh
  $* &gt; success.txt 2&gt; fail txt
  </code></pre>
  
  <p>fail.txt is empty. Why? I add that in another situation everything works, so the problem is only where the command prints information on both sterr and stdout.</p>