title: bash how to get async command output to variable
body: <p>i want to know how can we get command output to variable in bash</p>
  
  <p>here is my code</p>
  
  <pre><code>#!/bin/bash
  opt="svcrack -v -u100 -r1-9999 -z3 10.0.0.1"
  opt2="$($opt)"
  
  echo "myout output $opt2"
  </code></pre>
  
  <p>output</p>
  
  <pre><code>myout output 
  </code></pre>
  
  <p>not working inside function :( </p>
  
  <pre><code>function zwork(){
  
  opt=$(svcrack -v -u100 -r1-9999 -z3 10.0.0.1 2&gt;&amp;1)
  
  echo "myout output $opt"
  }
  
  out=$(zwork)
  </code></pre>