Grep: count number of matches per line
grep -o -n '[{}]' <filename> | cut -d : -f 1 | uniq -c
The output will be something like:
3 1
1 2
Meaning 3 occurrences in the first line and 1 in the second.
Taken from https://stackoverflow.com/a/15366097/3378354 .
After reading various solutions, I think this is the easiest approach to the problem:
while read i; do echo $i |grep -o "matchingString"| wc -l; done < input.txt