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:
car tramway bus train skate rollerblade bike
Dictionary - one dictionary word on line, no repetition, something like this:
car tramway bus train bike aeroplane submarine
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
car tramway bus train bike
And if you want number of these words just pipe it to
grep -f dictionary search_log | wc -l
And result will be 5.