In each iteration, the egrep on an average takes around 50-60 seconds to search. Ther'es nothing significant in the loop other than egrep. And when we checked the timestamps, egrep is what slowing it down.
Is it possible to improve egrep's performance ? Or do we need to use perl or any other pattern search ?
In addition to the above, can you post an example of this $key? Perhaps using a regex optimizer will help. If readability to external assembly of a $key is done, you could do something like this as well.
I have uploaded the $key as a screenshot as I don't have the text version right now..., it's a big string concatenated by "|".
Can you pls. tell me which is better than egrep....
grep.. perl... sed...?
And why should egrep take around 50..60 seconds in an iteration ...?
And will splitting the ${PICKUP_DIR}/new_update file into multiple files and searching each file until a match is found, help in anyway...?
I had a feeling it was a bloaded regular expression, a regex optimizer is what you need.
You are giving egrep (which is a grep -E dedicated) a pile of 'check for this or this or this or this'. The form you have it in is quite unwieldy. If that could be reduced to this ...
TP-CAP-P[0-9]{9}-[0-9]{9}
If your not keen on the regular expression thing you can use a program like regex buddy to load your data in (or a dozen mb or so) and then test it.