title: How to check the extension of a filename in a bash script?
body: <p>I am writing a nightly build script in bash.<br>
  Everything is fine and dandy except for one little snag:</p>
  
  <pre><code>
  #!/bin/bash
  
  for file in "$PATH_TO_SOMEWHERE"; do
        if [ -d $file ]
        then
                # do something directory-ish
        else
                if [ "$file" == "*.txt" ]       #  this is the snag
                then
                       # do something txt-ish
                fi
        fi
  done;
  </code></pre>
  
  <p>My problem is determining the file extension and then acting accordingly.  I know the issue is in the if-statement, testing for a txt file.  </p>
  
  <p>How can I determine if a file has a .txt suffix?</p>