title: Print command output while storing in variable
body: <p>I am running unit tests in a bash shell, which can take some time to finish, and those tests print output as they run. I want this output to be printed, and I also want the output to be stored in a variable. However, I want these things to be done concurrently if possible, like the <code>tee</code> command does when writing to a file. Perhaps <code>tee</code> works in this case too…</p>
  <p>So I am currently doing this:</p>
  <pre><code>output=$(ginkgo -r -cover)
  echo &quot;$output&quot;
  </code></pre>
  <p>However, this obviously won't print the unit test output until all the tests have run. So how can I get the output to print as the tests run while also storing that output in a variable?</p>