dovoljno je samo dodati -o switch
dakle
koliko=`cat $i | grep -o "nesto"| wc -l`
izvod iz man grep
-o, --only-matching
Print only the matched (non-empty) parts of a matching line, with each such part on a separate output line.
ukoliko "nesto" nije regex, verovatno je efikasnije koristiti fgrep ... ( tj. grep -F )
Attempt all the problems. Those you can do, don't do. Do the ones you cannot.