title: shell script to loop through wildcard matched directories
body: <p>I am trying to loop through directories that match a wildcard. This works fine in command line. But does not work in Shell script. Any idea?</p>
  
  <pre><code>   for dirs in /var/www/html/my.domain.com/v*; do echo $dirs; done;
  </code></pre>
  
  <p>The above command lists</p>
  
  <pre><code>  /var/www/html/my.domain.com/v1.0
    /var/www/html/my.domain.com/v1.2
    /var/www/html/my.domain.com/v2.0
  </code></pre>
  
  <p>Here is the Shell script version. Its not working:</p>
  
  <pre><code> dirs=/var/www/html/my.domain.com/v*
   for dir in $dirs
   do
     echo "$dir"
   done
  </code></pre>
  
  <p>Tried this too:</p>
  
  <pre><code>dirs=`/var/www/html/my.domain.com/v*` #back quotes
  for dir in $dirs
  do
     echo "$dir"
  done
  </code></pre>