title: How to store standard error in a variable
body: <p>Let's say I have a script like the following:</p>
  
  <p>useless.sh</p>
  
  <pre><code>echo "This Is Error" 1&gt;&amp;2
  echo "This Is Output" 
  </code></pre>
  
  <p>And I have another shell script:</p>
  
  <p>alsoUseless.sh</p>
  
  <pre><code>./useless.sh | sed 's/Output/Useless/'
  </code></pre>
  
  <p>I want to capture "This Is Error", or any other stderr from useless.sh, into a variable. 
  Let's call it ERROR.</p>
  
  <p>Notice that I am using stdout for something. I want to continue using stdout, so redirecting stderr into stdout is not helpful, in this case.</p>
  
  <p>So, basically, I want to do</p>
  
  <pre><code>./useless.sh 2&gt; $ERROR | ...
  </code></pre>
  
  <p>but that obviously doesn't work.</p>
  
  <p>I also know that I could do</p>
  
  <pre><code>./useless.sh 2&gt; /tmp/Error
  ERROR=`cat /tmp/Error`
  </code></pre>
  
  <p>but that's ugly and unnecessary.</p>
  
  <p>Unfortunately, if no answers turn up here that's what I'm going to have to do.</p>
  
  <p>I'm hoping there's another way.</p>
  
  <p>Anyone have any better ideas?</p>