title: Optimal way to recursively find files that match one or more patterns
body: <p>I have to optimize a shell script, but after one week, i didn't succeed to optimize it enough.</p>
  
  <p>I have to search recursively for .c .h and .cpp file in a directory, and check if word like this exist:
  "float short unsigned continue for signed void default goto sizeof volatile do if static while"</p>
  
  <pre><code>words=$(echo $@ | sed 's/ /\\|/g')
  
  files=$(find $dir -name '*.cpp' -o -name '*.c' -o -name '*.h' )
  
  for file in  $files; do
  (
          test=$(grep -woh "$words" "$file" | sort -u | awk '{print}' ORS=' ')
          if [ "$test" != "" ] ; then
            echo "$(realpath $file) contains : $test"
          fi
  )&amp;
  done
  wait
  </code></pre>
  
  <p>I have tried with xargs and -exec, but no result, i have to keep this result format:</p>
  
  <blockquote>
    <p>/usr/include/c++/6/bits/stl_set.h contains : default for if void</p>
  </blockquote>
  
  <p>Maybe you can help me (to optimize it)..</p>
  
  <p>EDIT: I have to keep one occurence of each word
  YES: while, for, volatile... 
  NOPE: while, for, for, volatile...</p>