title: Get command output into variable
body: <p>In bash I got all the names from services which are balanced from /etc/haproxy. But now I want to store all these intro a $srv variable in order to continue my healthcheck script.   </p>
  
  <pre><code>for filename in /etc/haproxy/*.cfg; do
      for ((i=0; i&lt;=0; i++)); do
        srv = $(echo $filename | awk -F'[/.]' '{print $4}')
        echo $srv
      done
  done
  </code></pre>
  
  <p>Using echo $filename | awk -F'[/.]' '{print $4}' is showing the correct microservices names like:
  service1
  service2
  service3</p>