file 2 are the search keys to search in file 1 if any of the search key is found in file 1 it should return the whole line of file 2 such that the desired output is:
key is empty when you're reading file1 (you need to switch the order of your operands so the keys will be read from file2 before you try to find the keys in file1, and
your keys are single words (e.g., example.com ), but $2 in file1 is a comma separated list of possible keys. The expression ( $2 in key ) will only be true if a single key from file2 is the only key in the list of keys in a line in file1.
Thank you very much for the clear explanation about awk. The grep script works perfectly fine but just one another concern. If in case my output is just the same as above but with a slight change like this, if the search is found it has to return the whole line else just the first column