I have a number of search logs that I want to compare against certain dictionary files. Once I process the search logs to filter out certain entries and get all the search terms into separate lines, what is an easy way to figure out how many of the search terms are present in the dictionary file?
I'll take the preparation of input aside and assume these inputs:
Search log - one searched term on line, no repetition, something like this:
Dictionary - one dictionary word on line, no repetition, something like this:
And if you want to select lines from search log, which are in dictionary, you can do it like this:
grep -f dictionary search_log
It'll return
And if you want number of these words just pipe it to
wc -l
grep -f dictionary search_log | wc -l
And result will be 5.