I have a list of search terms in termlist.txt, and a directory /dir/scripts which has a lot of scripts inside.

How would I easily determine if any file in /dir/scripts contains any term in the list from terms.txt?

This is on a unix server.

grep -Fxrlf termlist.txt /dir/scripts

where grep options are

  • -f file use patterns from file
  • -F patterns are fixed strings, not regular expressions
  • -x the pattern must match the whole line (you may not want this)
  • -l output only the filenames containing the match
  • -r recursive
  • this seems to be exactly what I needed. Thanks – Kefka Sep 30 '15 at 1:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.