Grep all at once

grepperformance

The script I have receives arguments and needs to grep through another file. Script loops through every argument.

Is there a way to collect the arguments in a single search string and grep with OR ? I'd like to do this to improve the speed hoping that searching everything at once will make my script faster. Appreciate any ideas.

Best Answer

egrep (or grep -E) can do OR:

egrep "string|string|string" <file>
Related Question