General
cancel
Showing results for 
Search instead for 
Did you mean: 

Difference between grep and egrep

SOLVED
Go to solution
Trenta Angelo
Contributor

Difference between grep and egrep

Hi all,

I???d like to kow the meaning of this code lines,
Why it is using ???egrep??? instead of grep?

......................................
#Runs the utility in report mode
xsm_check_erregistrations -r 0 > /tmp/log 2>&1

if [ ! -a /tmp/log ]
then
#no stale registrations
exit 0
fi
stalereglist='egrep "Stale ER Client:" /tmp/log | awk -F ":" '[print $4]''
.............................................


What is, in general, the difference between grep and egrep?

Regards, Angelo Trenta
I will work harder, HP-UX is always right
5 REPLIES
Jeanine Kone
Trusted Contributor

Re: Difference between grep and egrep

According to the man pages:

egrep is maintained for backward compatibility. It has been replaced with the -E option of grep (for Extended regular expressions).
A. Clay Stephenson
Acclaimed Contributor

Re: Difference between grep and egrep

egrep is a fairly archaic command these days. The preferred method is to use grep -E rather than egrep. The difference is that the regular expression processing is more powerful in egrep (or -E) at the cost of speed. In your example, it appears that grep would work as well. The other major difference is that multiple patterns can be specified in the 'extended' version.

Man grep for more details.
If it ain't broke, I can fix that.
V. V. Ravi Kumar_1
Respected Contributor

Re: Difference between grep and egrep

hi,

grep is used to search for a single pattern

ex: grep
whereas egrep searches multiple expression at a time

ex: egrep ' expression2>

in ur case it is searching any of Stale ER or Client.

regds
Never Say No
James R. Ferguson
Acclaimed Contributor

Re: Difference between grep and egrep

Hi:

'egrep' stands for "extended" grep. If you use the '-E' option of 'grep' you will achieve the same functionality. Similarly, the '-F' option of 'grep' yields fixed-string searches in lieu of using 'fgrep'. See the man pages for 'grep' for more information.

Regards!

...JRF...
MANOJ SRIVASTAVA
Honored Contributor
Solution

Re: Difference between grep and egrep

Hi Angela


You may like to look at this


:http://www.ntlug.org/archive/tp/shell_ccox/img8.htm



Manoj Srivastava