title: Piping to grep and using regex
body: <p>Basically what I want to do is parse lines in a file and return usernames. Usernames are always surrounded in &lt; and >, so I want to use regex to match eveything before (and including) the &lt; and everything after (and including) the >, and then invert my match. I understand that grep -vE should be able to do this.</p>
  
  <p>My script looks a little something like this so far:</p>
  
  <pre><code>#!/bin/bash
  while read line; do
          echo $line | grep -vE '(.*&lt;)|(&gt;.*)'
  done &lt; test_log
  </code></pre>
  
  <p>And test_log consists of the following:</p>
  
  <pre><code>Mar  1 09:28:08 (IP redacted) dovecot: pop3-login: Login: user=&lt;emcjannet&gt;, method=PLAIN, rip=(IP redacted), lip=(IP redacted)
  Mar  1 09:27:53 (IP redacted) dovecot: pop3-login: Login: user=&lt;dprotzak&gt;, method=PLAIN, rip=(IP redacted), lip=(IP redacted)
  Mar  1 09:28:28 (IP redacted) dovecot: imap-login: Login: user=&lt;gconnie&gt;, method=PLAIN, rip=(IP redacted), lip=(IP redacted), TLS
  Mar  1 09:27:25 (IP redacted) dovecot: imap-login: Login: user=&lt;gconnie&gt;, method=PLAIN, rip=(IP redacted), lip=(IP redacted), TLS
  </code></pre>
  
  <p>However, when running my script, nothing is returned, despite when I test the regex in something like regexpal with an inverse match it does exactly what I want. What am I doing wrong?</p>