Finding my lost file by searching for words in it

Got a question for you guys...I am searching through a public directory (that has tons of files) trying to find a file that I was working on a longggggg time ago. I can't remember what it is called, but I do remember the content. It should contains words like this:

Joe
Pulvo
botnet
zeus
command
control

There are several hundred files in this directory, so I was trying to figure out a command that will locate this file, which contains all of these words. I wanted to put these 6 words into a file using VI, and then use that file to find what I am looking for.

I know I could do:

grep -R -l 'String to find'  

but I would rather use the file to make sure all of the words are in it. I think I need to write a short script so I can replace 'String to find' with an ambiguous term, which is my problem. Could I just use $n instead of 'String to find' and increment $n so it will move lines down each time, thus searching for a new word?

Since I tend to have organizational problems, it would be nice to have this script work for any input, so my goal is to not hard code specific words into the algorithm.

thanks

grep -R -l -f file_with_strings

For OR patterns it's easy:

grep -f patterns -Rl PATH

If you want AND patterns, you need a script like this (it's just my attempt):

#!/bin/sh

# usage: ./script 'WORD1 WORD2 WORD3 ...' PATH 

words=$1
mypath=$2

find "$mypath" -type f | while read f; do
  found=1
  for word in $words; do
      if ! grep -q "$word" "$f" 2>/dev/null; then
          found=""
          break
      fi
  done
  if [ "$found" ]; then
      echo "$f";
  fi
done

That looks good, but I was wondering if I could do it this way. Say those words are located in a file, and for example we will call it words.txt. Can I just plug in that file, instead of listing all of the words? Like so...

grep -f (wc -l words.txt) -R1 *.txt

??? I really don't know if the line count part would actually work, and if it would check all of the words or just the first occurrence (I could probably use sed for that too), but it just seems easier than writing out a whole script.

Basically, I am wondering if I can replace the "pattern" with an actual file.

grep -f <filename>

The -f means: use the content of the coming file as the pattern to search for. Passing it the argument of how many lines the file has will not work.

The main question - if you want find files with ALL your words or just with ANY of your words.

For the latter grep command is enough, for the former - you need a script. Whether this script will get your patterns (words) from a file or on the command line - it's not a problem at all. You can change my script like this (you can't have patterns-words with spaces though but it's easy enough to modify the script to catch it) :

# usage: ./script WORDS_FILE PATH 

words=`cat $1`
mypath=$2
...