Here is really simple trick how to search for strings that are the same within two different files.
For presenting purposes I created two files with some text in it. Some text is the same, some not.
> $ cat file1.txt test1 test2 test3 test4 test5
> $ cat file2.txt lala1 lala2 test3 test4 lala4 lala6
Here is how to find strings that are the same within both files:
> $ cat file1.txt file2.txt | sort | uniq -c | grep "2 " 2 test3 2 test4
So, strings test3 and test4 occurring in both files.