title: How to pass a list of files with a particular extension in a for loop in bash
body: <p>First of all, hi to everyone, that's my first post here.
  I swear I have checked the site for similar questions to avoid the "double post about same argument" issue but none of them answered exactly to my question.
  The problem is that in the code below I always get the <code>"There are no files with this extension"</code> message when I call the script passing it an extension as first argument.</p>
  
  <pre><code>#!/bin/bash
  if [ "$1" ];
      then
          file=*."$1";
          if [ -f "$file" ];
              then
                  for i in "$file";
                  [...do something with the each file using "$i" like echo "$i"]
              else
                  echo "There are no files with this extension";
          fi;
       else
           echo "You have to pass an extension"
       fi;
  </code></pre>
  
  <p>I tried using the double parenthesis, using and not using the quotes in the nested if, using <code>*."$1"</code> directly in the if, but none of this solution worked.</p>