title: How do I use regular expressions in bash scripts?
body: <p>I want to check if a variable has a valid year using a regular expression. Reading the <a href="http://www.gnu.org/software/bash/manual/html_node/Conditional-Constructs.html" rel="noreferrer">bash manual</a> I understand I could use the operator =~</p>
  
  <p>Looking at the example below, I would expect to see "not OK" but I see "OK". What am I doing wrong?</p>
  
  <pre><code>i="test"
  if [ $i=~"200[78]" ]
  then
    echo "OK"
  else
    echo "not OK"
  fi
  </code></pre>