Script to find all the files that contain any of the words present in another file

Hi All,

I am new to UNIX and shell scripts and also new to this forum.

I need a script to find all the files in a directory that contain any of the strings present in another file.

Please provide me the script or if you could provide pointers to any link in this forum it would be helpful.

Thanks,
TSK

you mean IN the files contents or in the filenames?

IN the file contents.

Say I have files f1,f2,f3,f4,f5 in a directory D1.

The files have these strings respectively in their contents.

f1 - 0024020080520
f2 - 0015020080520
f3 - 0020020080520
f4 - 0010020080520
f5 - 0030020080520

Now, say I have another file M1 in another directory D2 which contains the following strings.

0024020080520
0015020080520
0010020080520

The script I am looking for needs to read file M1 fromD2 and search D1 for the files that contain the string in its contents and list the names of f1,f2 and f4.

Hope, I am clear now.

Sorry for not putting it clearly in the first place.

Thanks,
TSK

for i in `cat Full_path_of_D2/M1`
do
grep -l $i Full_path_of_D1/*
done

Thanks
Penchal

while read line
do
	for i in *
	do
		grep $line $i 1>/dev/null
		if [ $? -le 0 ]
		then
			echo $i
		fi
	done
done < checkfile