title: bash: Run multiple command in background, store output in variable
body: <p>How do I run a sequence of commands in parallel, and store their output in a variable?</p>
  
  <p>I've tried:</p>
  
  <pre><code>output=`(echo -n "started "; sleep 2; echo "stopped") &amp;`
  
  echo "output before=$output"
  wait
  echo "output after=$output"
  </code></pre>
  
  <p>And got a pause of two seconds, followed by:</p>
  
  <pre><code>output before=started stopped
  output after=started stopped
  </code></pre>
  
  <p>I expected:</p>
  
  <pre><code>output before=
  &lt;2 seconds pause&gt;
  output after=started stopped
  </code></pre>
  
  <p>How do I run a sequence of commands in the background, and store their output in a variable?</p>