Find 2 occurrences of a word and print file names

I was thinking something like this but it always gets rid of the file location.

grep -roh base. | wc -l
find . -type f -exec grep -o base {} \; | wc -l

Would this be a job for awk? Would I need to store the file locations in an array?

I'm not sure I understand what you want to achieve.
grep usually takes 0 or more options, then a pattern (list / file), then a file (list) to search. In your first command, either pattern or file (list)is missing, so grep will fall back to search stdin, which is no file location.
The -h option will suppress the output of the file names, and piping stdout to wc -l will just print the count of lines.
The second command will execute grep for each file found, applying the default -h for single file search. Again, wc -l will just output a count of lines.

Try this

grep -l -m 2 -w "\<base\>" *

Every standard grep has the "-c" switch, which counts the occurrences of the given regexp, hence:

grep -c "<regexp>" /path/to/file

or, if you want to base a logical decision upon it:

if [ $(grep -c "<regexp>" /path/to/file) -eq 2 ] ; then ...

I hope this helps.

bakunin