Ah, good idea using grep -o. That does indeed find multiple matches in a single line.
That, however, won't work correctly if some of the matches are overlapping. Eg. if the second file has abcdef and the first file has the two strings abcd and cdef, grep will only find the abde part. As a workaround, you could run grep once for each string in the first file. Thus, we get (I think)
( while read; do grep -oFe "$REPLY" secondfile | wc -l; done ) < first +file
In reply to Re^3: search text file
by ambrus
in thread search text file
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |