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
Post a Comment