Link to home
Start Free TrialLog in
Avatar of lolaferrari
lolaferrariFlag for United Kingdom of Great Britain and Northern Ireland

asked on

bash script alternative to grep -v

if I have lots of grep -v in my shell script will it slow it down or is there are limit to how many I can put in egrep '(word|word2|word3) ? Is there a better way to do this ?
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>> if I have lots of grep -v in my shell script
What are you 'greppinh' for then? A process list perhaps? Can you show an example?
Avatar of lolaferrari

ASKER

Oh yes, silly me - maybe not the best example. The little script just hangs. Does the grep -f extract all the similar patterns found in file?
Yes, the -f option means grep is looking in a specified file for patterns.

When your script hangs, just call it explicitly with the -xv option, you'll get to see debugging information with variable assignments etc. This should help you finding  out why the script is hanging.

For example:

bash -xv your_script
how are you using grep in your script?