1

Is it possible to use grep with a text file of keywords?

For example instead of grep -r "keyword" directory/ Something like grep -r keywordList.txt includes/

where keywordList.txt is full of a bunch of keywords?

1
  • You're right... done. – sbuck Jan 30 '10 at 22:30
5

Try fgrep.

fgrep -rf keywords.list includes/

keywords.list must be one keyword per line, with no extra whitespace and no regular expressions.

2
  • worked perfectly – sbuck Jan 30 '10 at 22:51
  • On most systems fgrep just maps directly to "grep -F". Depending on your work flow, knowing that may be more useful in the long run. – Scott Pack Jan 31 '10 at 2:15

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.