This question already has an answer here:
If I have a file
words_of_interest.txt with one word per line, is there a way to use
awk (or some other *nix tools) to obtain the number of times each of these words occurs in another text file
my_text.txt, using only one pass?
Currently I am
grep -c'ing the text for each word, but this is quite slow because the text is large, and there are several hundred words to search for.
EDIT: providing sample input and output:
[words_of_interest.txt] joe hi [my_text.txt] hi joe hi jack nice day today [output] joe 1 hi 2
EDIT2: To those who marked this question as duplicate: the question you point to is about counting all the words, whereas this one is about counting only the instances of a specific pre-defined set of words.