Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
Do accept some answers. – Tobu Jan 30 '10 at 22:19
You're right... done. – Susan Jan 30 '10 at 22:30
up vote 5 down vote accepted

Try fgrep.

fgrep -rf keywords.list includes/

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

share|improve this answer
worked perfectly – Susan 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 posting your answer, you agree to the privacy policy and terms of service.

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