Quote:
|
grep -o <string> <file> | wc -w
|
I tried using grep with the "-o" option and it gives me this error:
grep: illegal option -- o
What does "-o" option do?
I also need to find an occurence of a certain string within a file. Currently I'm using:
Code:
grep -c 'abc' sample.txt
But the code above only counts the occurrences per line. How will i get the total count of the 'abc' words regardless of how many occerence they have per line?
Example:
This is line 1
abc and
abc
This is line 2
abc