cancel
Showing results for 
Search instead for 
Did you mean: 

egrep question

Allanm
Super Advisor

egrep question


I want to egrep for certain fields which are not existing in the current log files and am getting errors for that...

egrep "'^20090220.14'|'^20090220.15'|'^20090220.16'|'^20090220.17'|'^20090220.18'"

Some of the times are in future and logs don't have those entries and I get errors for them ... what should I do?

Thanks,
Allan
3 REPLIES
Steven Schweda
Honored Contributor

Re: egrep question

> what should I do?

First, show an actual command with its actual
output. "I get errors" is not a useful
description of what you did, nor of what
happened when you did it.
Dennis Handly
Acclaimed Contributor

Re: egrep question

>I want to egrep for certain fields

Why not use just grep?
grep -e "'^20090220.14'" -e "'^20090220.15'" ...

Any reason you have single quotes inside of double? This will hide the "^" if you intend to anchor at the start of the line:
grep -e "^20090220.14" -e "^20090220.15" ...

>which are not existing in the current log files and am getting errors for that

If they don't exist, you can't find them. What grep errors would you get?
Fredrik.eriksson
Valued Contributor

Re: egrep question

Why not just do it like this?
egrep "^20090220\.1[4-8]" file.txt

Seems like a mess to make several "or"-statements for this.

Also, the quotation seems unneccessery as Dennis pointed out.

And you should assign some points to those who answered a week ago.

Best regards
Fredrik Eriksson