Hey everyone,
I know how to use grep, sed and awk in its most basic form, but I need to know how can I use either one of these commands or another to perform this task.
I Know how to count matching lines by piping it to wc. I want to know how can I count a matching pattern on one line, for example:
Quote:
The big bear jumped over the big fence.
|
I would like to know how many times the word
big appears on one line, in our case 2 times.
In the past, I've used xargs to put each word on a separate line, then piped it to grep and wc to get the result.
If you know a better way I can achieve the same result please let me know.
Thanks in advance