title: Setting variable in bash -c
body: <p>I try to set variable which get interface ip-address from <code>ifconfig</code> and read it later. But when I execute a <code>echo</code> command, variable still empty. Please look at my code:</p>
  
  <pre><code>/usr/bin/bash -c "HOST_IPS=$(/usr/bin/ifconfig | /usr/bin/awk 'BEGIN {cnt=0} {if($0 ~ /inet / &amp;&amp; cnt==1) {print $2} cnt++}'); echo $HOST_IPS"
  </code></pre>
  
  <p>But /bin/echo work fine with same command:</p>
  
  <pre><code>/usr/bin/bash -c "echo $(/usr/bin/ifconfig | /usr/bin/awk 'BEGIN {cnt=0} {if($0 ~ /inet / &amp;&amp; cnt==1) {print $2} cnt++}')"
  </code></pre>