title: ksh redirect stdout and stderr to different processes
body: <p>How can one redirect stdout pipes and stderr pipes nn ksh on UNIX? (Not Linux). </p>
  
  <p>The following works to redirect to files:</p>
  
  <pre><code>x=0
  while [[ "$x" -lt 100 ]]; do
      echo "junk" &gt;&amp;2
      echo "$x log test"
      echo "junk err" &amp;&gt;2
      echo "$x err test" &gt;&amp;2
      x=$(($x+1))
  done 2&gt;out1.err 1&gt;out1.log
  </code></pre>
  
  <p>I've tried things to redirect pipes to other processes, like the following but this doesn't work:</p>
  
  <pre><code>x=0
  while [[ "$x" -lt 100 ]]; do
      echo "junk" &gt;&amp;2
      echo "$x log test"
      echo "junk err" &amp;&gt;2
      echo "$x err test" &gt;&amp;2
      x=$(($x+1))
  done 2&gt;&amp;3 | sort -u &gt; out2.log 3&gt;&amp;1 | sort -u &gt; out2.err
  </code></pre>