I am trying to find the amount of times a match occurs from a list of patterns given in the pattern file, to the target file. Here are example target and pattern files:
are bare barely be beware care clever
I know that I can do
grep -F -c -f patternFile targetFile
to get the number of strings that have one or more match in the pattern file in them, but I want to count the total number of matches.
Here is where grep is not returning what I really want: In the example above
beware is matched by both
be and should count as two matches, but is only counted as one match by the grep statement above.