title: Shell Scripting: RegEx in if Statement
body: <p>I can't seem to figure out how to write a regex correctly in an <em>if</em> statement. I wanted it to print out all the lines with "End Date" in it.</p>
  
  <p>NUMBERS contains a text file with the following content:</p>
  
  <pre><code>End Date    ABC ABC ABC ABC ABC ABC
  05/15/13    2   7   1   1   4   5  
  04/16/13    4   3   0   1   3   6  
  03/17/13    6   9   3   8   5   9  
  02/18/13    8   2   7   1   0   1  
  01/19/13    1   9   2   2   5   2  
  12/20/12    7   2   7   1   0   1 
  </code></pre>
  
  <p>Here is a snippet of my code that I am having problems with:</p>
  
  <pre><code>if [ -f $NUMBERS ]
  then
          while read line
          do
                  if [ $line = ^End ]
                  then
                          echo "$line"
                  else
                          echo "BROKEN!"
                          break                   
                  fi
          done &lt; $NUMBERS
  else
          echo "===== $NUMBERS failed to read  ====="
  fi
  </code></pre>
  
  <p>The output is:</p>
  
  <blockquote>
    <p>Broken!</p>
  </blockquote>