title: Put the MySQL command output to a variable and also print on the screen?
body: <p>I'm really ashamed to ask this question but is there really a way to redirect a MySQL output (e.g. ls -l) to STDOUT and also assign to a variable at the same time? I tried this:</p>
  
  <pre><code>san@pcjq:~$ exec 5&gt;&amp;1
  san@pcjq:~$ SQL=$(mysql -uroot -p mysql -e "SELECT Host,User,Password FROM user;" | tee &gt;(cat - &gt;&amp;5))
  Enter password: 
  Host    User    Password
  127.0.0.1   root    *CD0B39440D9701958FDA10ED6B02E3507DC28EB
  %   slvUser *8E6F445A9F0E7AA18DA1D830CC61B5AAC9C606
  localhost   root    *CD0B39440D9701958FDA10ED6B02E3507DC28EB
  localhost   san *8E6F4A10ED6B00E7AA18DA10EDD830CC61B5AAC9C606
  localhost   debian-sys-maint    *1BF46B679FC8911CD06712EC782E446F01201CB7
  </code></pre>
  
  <p>which is not really the exact representation of the output that we normally see on the screen. On the other hand:</p>
  
  <pre><code>SQL=$(mysql -uroot -p mysql -e "SELECT Host,User FROM user;" &gt;&amp;2)
  </code></pre>
  
  <p>does print the correct output on the screen but noting gets in the variable (for obvious reason). Does anyone know any a workaround? Cheers!!</p>