Grepping a list of words

Jack L. Stone jacks at
Thu Aug 12 12:38:59 UTC 2010

At 05:14 PM 8.12.2010 +0530, Ashish SHUKLA wrote:
>Jack L Stone writes:
>> Kindly appreciate help with how to grep (or similar) a list of words to
>> determine if any of them are in a file rather than grepping one word at a
>> time.
>% egrep 'word1|word2|word3|...|wordn' filename.txt
>'word1|word2|word3|...|wordn' is the regular expression, so if you can
>minimize it better for you :).
>Ashish SHUKLA      | GPG: F682 CDCC 39DC 0FEA E116  20B6 C746 CFA9 E74F A4B0

Thanks for the replies. This suggestion won't do the job as the list of
words is very long, maybe 50-60. This is why I asked how to place them all
in a file. One reply dealt with using a file with egrep. I'll try that.

Appreciate the help and any others in case the one doesn't work.

All the best,

Happy trails,
Jack L. Stone

System Admin

More information about the freebsd-questions mailing list