title: How to match pattern at the end of line/text
body: <p>I am very new to bash. So if this is a pretty basic question, please pardon me.</p>
  
  <p>I am trying to replace file extension '<code>.gzip</code>' with '<code>.gz</code>'.</p>
  
  <p>E.g.:</p>
  
  <pre><code>testfile.xml.gzip =&gt; testfile.xml.gz
  </code></pre>
  
  <p>Someone has written a script which does this:</p>
  
  <pre><code>GZIP=`echo ${FILE} | grep .gz`
  
      .
      .
      .
  
  FILE=`echo ${FILE} | sed 's/.gz//g'`
  </code></pre>
  
  <p>The first line wrongly matches <code>testfile.xml.gzip</code> file. The <code>grep .gz</code> matches the text in filename which is in-between, whereas I need it to match only if it is at the end of the filename. Can anyone help me with how to correct this problem? In short, I need to know the expression which matches pattern the end of the line/text.</p>