[Novalug] bash & grep question - best for optimizing?
Ross Patterson
RossPatterson at Comcast.Net
Mon Nov 13 18:28:43 EST 2006
At 09:08 11/13/2006, Nick Danger wrote:
>2. Should I do one grep for each pattern, or a single grep with multiple
>matches?
Assuming a modern grep,
grep -rl -E "(pattern1)|(pattern2)|(pattern3)|(pattern4)" .
is likely to be the highest performance and most reliable. In
particular, assuming your hash-structured directory is kind of broad,
grepping recursively on "." instead of on "*" will prevent the shell
from trying to expand "*" into a list of subdirectory names. There
is a limit on the size of a command string, and this will avoid it
and also cut down on the storage size to launch the command.
Ross
More information about the Novalug
mailing list