Zsh/glob expansion in for loop

From raju

< Zsh

glob expansion in for loop

Do not use quotes if you want the expression to be expanded using wildcards. So the correct way is

for fname in foo.????????
do
    echo "$fname"
done

The following will not expand the glob

for fname in "foo.????????"
do
    echo "$fname"
done


Enclosing characters in double quotes preserves the literal value of all characters within the quotes, with the exception of $, `, \

Ref:- https://superuser.com/questions/318738/does-a-wildcard-inside-double-quotes-glob