Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
2  
Do accept some answers. –  Tobu Jan 30 '10 at 22:19
    
You're right... done. –  Susan Jan 30 '10 at 22:30

1 Answer 1

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

 
discard

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.