![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Improve PHP Performance by Caching Database Results | iBot | Oracle Updates (RSS) | 0 | 04-06-2008 02:10 AM |
| How to improve grep performance... | pooga17 | Shell Programming and Scripting | 2 | 02-13-2008 04:34 AM |
| improve performance by using ls better than find | Nicol | UNIX for Advanced & Expert Users | 3 | 03-05-2004 05:53 AM |
| Help! Slow Performance | Neo | Post Here to Contact Site Administrators and Moderators | 6 | 08-25-2003 12:08 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
egrep is very slow : How to improve performance
We have an egrep search in a while loop.
egrep -w "$key" ${PICKUP_DIR}/new_update >> ${PICKUP_DIR}/update_record_new ${PICKUP_DIR}/new_update is 210 MB file 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 ? Could you please help ? |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Quote:
Look into the -f flag of grep. |
|
#3
|
|||
|
|||
|
The value of $key changes on each iteration but ${PICKUP_DIR}/new_update doesn't change
|
|
#4
|
||||
|
||||
|
Quote:
Code:
egrep -f <file containing the different values of $key> ${PICKUP_DIR}/new_update
|
|
#5
|
||||
|
||||
|
Quote:
Code:
grep -E -w "`regexopt $key`" ... |
|
#6
|
|||
|
|||
|
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...? |
|
#7
|
||||
|
||||
|
Quote:
If the keys are separated by '|', then change the file such that each key is on a new line. Then Code:
egrep -f key.txt ${PICKUP_DIR}/new_update
|
||||
| Google The UNIX and Linux Forums |