title: How to count total number of matches of regular expression per file on AIX
body: <p><code>Grep</code> is usually used to display the lines containing a match of the specified pattern. Is there any way in AIX to display the total number of matches of the pattern in each file searched? That is to say, every match in every line should be counted.</p>
  
  <p>I tried <code>grep -c pattern filename</code>, but that only counts each matching line once however many matches it contains.</p>