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 ?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cat > file <<END
grep -f file

but note that
egrep '(word|word2|word3)'
will match exactly the same as
egrep 'word'

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Gerwin Jansen, EE MVETopic Advisor Commented:
>> 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?
lolaferrariAuthor Commented:
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?
Gerwin Jansen, EE MVETopic Advisor Commented:
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?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.