title: Checking correctness of an email address with a regular expression in Bash
body: <p>I'm trying to make a Bash script to check if an email address is correct.</p>
  
  <p>I have this regular expression:</p>
  
  <pre><code>[a-z0-9!#$%&amp;'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&amp;'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?
  </code></pre>
  
  <p>Source: <a href="http://www.regular-expressions.info/email.html" rel="nofollow noreferrer">http://www.regular-expressions.info/email.html</a></p>
  
  <p>And this is my bash script:</p>
  
  <pre><code>regex=[a-z0-9!#$%&amp;'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&amp;'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?
  
  i="test@terra.es"
  if [[ $i=~$regex ]] ; then
      echo "OK"
  else
      echo "not OK"
  fi
  </code></pre>
  
  <p>The script fails and give me this output:</p>
  
  <blockquote>
    <p>10: Syntax error: EOF in backquote substitution</p>
  </blockquote>
  
  <p>Any clue??</p>