Results 1 to 5 of 5

Thread: Is there any Difference

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Sep 2006
    Answers
    23

    Question Is there any Difference

    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.


  2. #2
    Expert Member
    Join Date
    Sep 2006
    Answers
    477

    Re: Is there any Difference

    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!"

  3. #3
    Junior Member
    Join Date
    Sep 2006
    Answers
    23

    Exclamation Re: Is there any Difference

    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.


  4. #4
    Contributing Member
    Join Date
    Dec 2006
    Answers
    39

    Re: Is there any Difference

    "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.


  5. #5
    Expert Member
    Join Date
    Dec 2006
    Answers
    139

    Re: Is there any Difference

    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact