grep vs egrep vs grep -E


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers grep vs egrep vs grep -E
# 1  
Old 01-03-2012
grep vs egrep vs grep -E

i am confusing in grep Vs egrep vs grep -E.could any body explains very clearly?
# 2  
Old 01-03-2012
First please mention what Operating System and version you have.

In the Posix world there is one program "grep".
The extended expression version is invoked with "grep -E". This is the same as typing "egrep" but at some stage "egrep" may get withdrawn from the Posix standard. Personally I don't believe this and persist in using "egrep".

At general user level:
Code:
#Look for one string:
grep "string"
egrep "string"
grep -E "string"

#Look for either of two strings:
egrep "string1|string2"
grep -E "string1|string2"


# Look for either of four strings:
egrep "string1|string2|string3|string4"
grep -E "string1|string2|string3|string4"


Last edited by methyl; 01-03-2012 at 11:22 AM..
# 3  
Old 01-03-2012
so what you are saying is grep -E is useful while we are using extended regular expressions.right?
# 4  
Old 01-03-2012
Yes.
It's explained better in "man grep" than I can explain.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep/egrep fails with $ anchor?

The $ seems to fail for me. I'm using GNU grep 2.5.4 (that is, nothing out of the ordinary, just what came with my distro) but I can't get the final anchor $ to work for me. (^ works as usual.) Behavior without anchor: $ /bin/grep -E 'tium' file tritium tertium quid Expected behavior: $... (2 Replies)
Discussion started by: CRGreathouse
2 Replies

2. Homework & Coursework Questions

grep and egrep

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I have a text file. 1) How do I search for x and y? 'Find all lines that contain David and Emily' 2) How do I... (1 Reply)
Discussion started by: ninjagod123
1 Replies

3. UNIX for Dummies Questions & Answers

egrep / grep login name , logindate from xml

i have an xml file & need to extract two specific tags <loginName> & <lastLogin> for the users. In certain cases if a user has never logged in , the corresponding <lastLogin> tag for a <loginName> tag is absent. Can somebody help me out / guide me on how to go about it. (2 Replies)
Discussion started by: crux123
2 Replies

4. Shell Programming and Scripting

Using grep or egrep

So a few months ago, I decided to move away from using grep and decided to use egrep in this code that i'm writing. i figured egrep is more robust than grep. well, it appears it isn't. when i used egrep to search the log file for a script that looked like the following, egrep couldn't find... (3 Replies)
Discussion started by: SkySmart
3 Replies

5. Shell Programming and Scripting

grep/fgrep/egrep for a very large matrix

All, I have a problem with grep/fgrep/egrep. Basically I am building a 200 times 200 correlation matrix. The entries of this matrix need to be retrieved from another very large matrix (~100G). I tried to use the grep/fgrep/egrep to locate each entry and put them into one file. It looks very... (1 Reply)
Discussion started by: realwindfly
1 Replies

6. UNIX for Dummies Questions & Answers

Difference between grep, egrep & grep -i

Hi All, Please i need to know the difference between grep, egrep & grep -i when used to serach through a file. My platform is SunOS 5.9 & i'm using the korn shell. Regards, - divroro12 - (2 Replies)
Discussion started by: divroro12
2 Replies

7. UNIX Desktop Questions & Answers

Difference grep, egrep and fgrep

Hi All, Can anyone please explain me the difference between grep, egrep and fgrep with examples. I am new to unix environment.. Your help is highly appreciated. Regards, ravi (2 Replies)
Discussion started by: ravind27
2 Replies

8. Shell Programming and Scripting

grep/egrep end of pattern

Hi I use arp to get the mac-addresses of my hosts. # arp -a | grep 192.168.0. e1000g0 192.168.0.1 255.255.255.255 o 00:00:00:00:00:01 e1000g0 192.168.0.11 255.255.255.255 o 00:00:00:00:00:02 e1000g0 192.168.0.2 255.255.255.255 ... (12 Replies)
Discussion started by: domi55
12 Replies

9. Shell Programming and Scripting

egrep/grep result of more files

hi , I'm new at unix bash scripting, im playing a little bit with egrep/grep. I have serveral files and i do a search on those files, like "aki", the result is many rows outcoming and serveral of them are dubble because aki wil come more than ones in a file, how can i get a result that it... (3 Replies)
Discussion started by: tvrman
3 Replies

10. UNIX for Dummies Questions & Answers

grep/awk/egrep?

Hi, The input file "notifications" contains the following string. FRTP has 149 missing batches I want to search for : FRTP has missing batches As the number 149 is not important and will change. The commands I have tried. grep "FRTP has.*missing batches" notifications.txt... (3 Replies)
Discussion started by: whugo
3 Replies
Login or Register to Ask a Question