title: How to pipe file into `egrep`?
body: <p>I'm trying to get the hang of how to use <code>egrep</code> to count occurrences of something in a file.</p>
  
  <p>If I have a file like this, called <code>myfile</code>:</p>
  
  <pre><code>commas and stuff
  more things
  </code></pre>
  
  <p>Then I'm able to count the number of o's in the first like by :</p>
  
  <pre><code>head myfile | egrep -c "o" myfile
  </code></pre>
  
  <p>For some reason, I am not able to do this with pipes.  If I have a file like this called <code>mypipes</code>:</p>
  
  <pre><code>| my | pipes |
  </code></pre>
  
  <p>I tried this:</p>
  
  <pre><code>head mypipes | egrep -c "|" mypipes
  </code></pre>
  
  <p>That gives me an error <code>empty sub(expression)</code>, so I tried the following:</p>
  
  <pre><code>head mypipes | egrep -c "\|" mypipes
  </code></pre>
  
  <p>This gives me a value of "1", which is clearly wrong.</p>
  
  <p>How do I do this correctly? a full explanation rather than a one-off solution would be phenomenal.  thanks.</p>