Get total number of matches for a regex via standard unix command -


Assume that I want to calculate the number of "O" characters in the text

  Ousaidfa Ososogo  

My first idea was to do grep -co , but it returns 2 , because grep returns the number of mailing lines, and not the total number of matches can I use with grep to change this? Or maybe I should use awk , or any other command?

This will print the number of matches:

  echo "OUsdafa Ososago "| GRP-OO | Wc -l  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -