title: How to store the output of a command in a variable at the same time as printing the output?
body: <p>Say I want to <code>echo</code> something and capture it in a variable, at the same time I see it in my screen.</p>
  
  <pre><code>echo "hello" | tee tmp_file
  var=$(&lt; tmp_file)
  </code></pre>
  
  <p>So now I could see <code>hello</code> in my terminal as well as saving it into the variable <code>$var</code>.</p>
  
  <p>However, is there any way to do this without having to use a temporary file? <code>tee</code> doesn't seem to be the solution, since it says (from <code>man tee</code>) <em>read from standard input and write to standard output and files</em>, whereas here it is two times standard output.</p>
  
  <p>I am in Bash 4.3, if this matters.</p>