Let's say that I want to count the number of "o" characters in the text
oooasdfa
oasoasgo
My first thought was to do grep -c o
, but this returns 2
, because grep
returns the number of matching lines, not the total number of matches. Is there a flag I can use with grep
to change this? Or perhaps I should be using awk
, or some other command?