Is there any difference between egrep, fgrep in UNIX operating system. I want to know the difference and also I want to know which is efficient.
Is there any difference between egrep, fgrep in UNIX operating system. I want to know the difference and also I want to know which is efficient.
Yeps. There is a difference. fgrep can not search for regular expressions in a string. It is used for plain string matching.
egrep can search regular expressions too.
grep is a combination of both egrep and fgrep. If you don't specify -E or -F option, by default grep will function as egrep but will have string searching ability too.
Hence the best one to be used is grep.
Cheers,
Kalayama
[COLOR="Blue"][SIZE="2"]"If you are not living on the edge of your life, you are wasting space"[/SIZE][/COLOR]
Someone says "Impossible is nothing". The man next him says "Let me see you licking your elbow tip!"
That a very good explanation kalayama.Thanks for the same.But I am still confused why is that then one have the facility of egrep and fgrep in UNIX. What is special about them when grep has the option to take care of that.
"Ideally there should be only one grep command, but there is
not a single algorithm that spans a wide enough range of
space-time tradeoffs."
grep seaches specified pattern in file, where as egrep allows u to use regular expressions.
eg
OR condition will work only in egrep n not in grep
$egrep "CAT|MILK" inputfile
cat
milk
cat milk
this will return u the lines which will have either "cat" or "milk" or both.
where as grep scan only for specified pattern and not reg.expressions.
Hi,
fgrep = "Fixed GREP".
fgrep searches for fixed strings only. The "f" does not stand
for "fast" - in fact, "fgrep foobar *.c" is usually slower than
"egrep foobar *.c" (Yes, this is kind of surprising. Try it.)
Fgrep still has its uses though, and may be useful when searching
a file for a larger number of strings than egrep can handle.
egrep = "Extended GREP"
egrep uses fancier regular expressions than grep. Many people
use egrep all the time, since it has some more sophisticated
internal algorithms than grep or fgrep, and is usually the
fastest of the three programs
Regards
Nikhil Rattan