title: Find all files that contain all words/lines in another file
body: <p>I'm going to go right out and say this is a homework question, but I feel like I've exhausted my search online for anything relating to how to do this problem or I am just not wording it correctly for Google/Stackoverflow.</p>
  
  <p>The question starts out like this: File <strong><em>words</em></strong> contains a list of words. Each word is on a seperate line. Files <strong><em>story1, story2, ..., story100</em></strong> are short stories.</p>
  
  <p>It's a multi-part question, but the very last part is stumping me: Find out story files that contain all words that are in file <strong><em>words.</em></strong></p>
  
  <p>There was a question before it that's similar: Find out story files (print file names) that contain at least one word from file <strong><em>words</em></strong>.</p>
  
  <p>This one I solved by using grep:</p>
  
  <pre><code>grep -l -f words story*
  </code></pre>
  
  <p>I was under the impression that I would also have to use grep for the last problem, but I can't seem to find an option for grep or anything that would return only those files that match everything that is in a pattern file. It appears I may have to do this with a shell script, but unsure of where to start or if I even need grep for this. Any pointers on how to solve this problem?</p>
  
  <p>Thanks!</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>These are the correct answers from the solution the instructor gave us.</p>
  
  <p><strong>Question before main question:</strong> <code>grep -l -f words story*</code></p>
  
  <p><strong>Main question:</strong></p>
  
  <pre><code>for story in `ls story*`
  do
      (( match = 0 ))
  
      for word in `cat words`
      do
          if [ `grep -l $word $story` ]
          then
              (( match++ ))
          else
              break
          fi
      done
  
      if [ $match -eq `wc -w &lt; words` ]
      then
          echo $story
      fi
  done
  </code></pre>
  
  <p>Thanks everyone for their thoughtful input and answers and sorry I'm a little late on getting this out there.</p>