Files searching

I have a list of files in directory and i should write a script if any of these files contains words given in a text file test.txt. the words can be case ignored and word should match.

The output should be the name of the directory in which the file is present followed by list of file names
Eg:

dirfound filefound
dirfound filefound1
dirfound1 filefound
<code>
I traversed thrugh set of directories with
ls -ltr | grep "^d" | awk '{print $9}'

use the find command to search for you files instead of doing something like that. your command will break if files have spaces.