title: How to match file extension in bash?
body: <p>I want to call a function ONLY when the file name ends with <code>.request</code> but somehow it calls the function if <code>request</code> is <strong>sub-string</strong>.</p>
  
  <p>I <a href="https://i.stack.imgur.com/20ASq.png" rel="nofollow noreferrer">marked with red and green</a> the imported parts, on the right it's the output</p>
  
  <pre><code>for file in ${filesOrDir[*]}; do    
      if [[ -f "$file" ]]; then
          if [[ "$file"=*[".request"] ]]; then
              # Enters here when .request is a substring.
          fi
      fi
      if [[ -d "$file" ]]; then
              # ... some logics       
      fi
  done
  </code></pre>