I have 2 files. First file contains the list of row ID\'s of tuples of a table in the database. And second file contains SQL queries with these row ID\'s in \"where\" clause
Most of previous answers are correct but the only thing that worked for me was this command
grep -oi -f a.txt b.txt