You are not logged in. Login Now
 0-24   25-49   50-74   75-99   100-111      
 
Author Message
25 new of 111 responses total.
nephi
response 25 of 111: Mark Unseen   Mar 17 11:03 UTC 1995

Less powerful?  Now my interest has really been piqued.  
robh
response 26 of 111: Mark Unseen   Mar 17 11:38 UTC 1995

But egrep allows | to look for multiple patterns, and grep doesn't.
(So said the manual I checked, anyway.)
gregc
response 27 of 111: Mark Unseen   Mar 17 12:29 UTC 1995

Um, Valerie, you've got that backwards. egrep is more powerful, but slower.
egrep does full regular expression parsing, grep does limited regular
expressions. grep is ussually the smaller faster tool that you use for
most easy searches, and then you use egrep for the trickier ones. I think
egrep may have orriginally meant "extended grep".

The smaller argumetn doesn't hold true for the gnu versions of these programs
however. The gnu grep has all the code for all the versions of grep. It is
then installed with links to egrep and fgrep and it determines what set
of functionallity to use based on argv[0].
remmers
response 28 of 111: Mark Unseen   Mar 17 13:15 UTC 1995

And I will award the Unix Trivia prize of the day to the first person
to say what "grep" is an acronym for.
gregc
response 29 of 111: Mark Unseen   Mar 17 13:51 UTC 1995

"Global regular expression parser." or sometimes "(G)lobal (R)egular
(E)xpression search and (P)rint".

Although alot of people believe that this definition was rationalized
later, after the fact, and "grep" was either a meaningless word, or some
piece of slang that was personal to the author.
popcorn
response 30 of 111: Mark Unseen   Mar 17 14:56 UTC 1995

This response has been erased.

wind
response 31 of 111: Mark Unseen   Mar 17 16:16 UTC 1995

re #20:

I never identified anyone as being a twit or possibly being a twit. It
is a very different thing to say "there are twits" than saying "there
are twits, and so-and-so's one."

My apologies to nephi for implying his insidership.
popcorn
response 32 of 111: Mark Unseen   Mar 17 16:29 UTC 1995

This response has been erased.

remmers
response 33 of 111: Mark Unseen   Mar 17 17:28 UTC 1995

I've read that the "grep" program was a spinoff of the "ed" text
editor, which has the command

                g/<R.E.>/p

where the <R.E.> stands for any "regular expression" that the user
cares to enter -- "ed" will search its text buffer and display any
lines that match the regular expression.  At some point, the people
involved with developing Unix at Bell Labs decided that it would be
nice to have a standalone command, independent of "ed", that performed
this function, so they wrote such a program and called it "grep"
because of where it came from.

I read this in the writing of one of the Unix pioneers (Brian Kernighan
maybe?), so I give the "global regular expression print" explanation
the most credence.
nephi
response 34 of 111: Mark Unseen   Mar 17 19:53 UTC 1995

So . . . which is the better one to use in the twit filter?
popcorn
response 35 of 111: Mark Unseen   Mar 17 23:15 UTC 1995

This response has been erased.

davel
response 36 of 111: Mark Unseen   Mar 18 02:47 UTC 1995

Of course, if you want to avoid any extra milliseconds' delay, and you also
want mentions of the offending user's name to be suppressed as well as
that person's own words, you could use fgrep instead.
rcurl
response 37 of 111: Mark Unseen   Mar 18 05:19 UTC 1995

I came across a five page man of "regular expression", which didn't make
any sense to me, probably because they never explained why one would want
one. Can you explain in maybe five lines what's a "regular expression" andw
what good it is?
gregc
response 38 of 111: Mark Unseen   Mar 18 06:29 UTC 1995

A regular expression is a methodology for doing wildcarding in text
searches that is similiar to the wildcarding that you can do in "ls"
when you are looking for files. For instance, when you want to find
all the files in your home dir that start with "s" and end in ".c"
you might do "ls -al s*.c".

Regexp is a much more powerful extension of this concept. For instance,
suppose you wanted to grep a file for all instances of lines that had the
letter "S" in the forth column and the line ended with "flarb". You
would do:
    grep "^...S.*flarb$" filename

Explanation:
1.) The regexp must be in quotes to prevent your shell from interpreting
    the "*" character.
2.) The "^" signifies that the search must match starting at the beginning 
    of the line, otherwise the pattern can match anywhere in the line.
3.) A "." means to match *any* 1 character.
4.) The "S" is the literal letter "S" that you are looking for in the forth
    column.
5.) The "*" means to repeat the previous character as many times as necasary.
    Since the previous character is a ".", the ".*" construct means to
    match any and all characters up to the next pattern in the regexp.
6.) The "$" means that the preceeding item in the regexp must be at the
    end of the line. so "flarg" is only matched if it's the last characters
    of the line being searched.

The regexp could be read as follows:
  Match all lines that begin with any 3 characters and then an "S", end
  with the string "flarg", and have any amount of characters between those
  conditions.

Regexp is kind of hard to describe in abstract terms, giving an example
ussually works better. Based on the above you should be able to go back to
the man page and decipher all the other features it offers.

Note: I'm not a regexp expert and have never been able to remember all
the arcana involved in it. There's probably other ways to do my example
above that are simpler.


selena
response 39 of 111: Mark Unseen   Mar 18 07:13 UTC 1995

        You more of an expert than me!
srw
response 40 of 111: Mark Unseen   Mar 18 08:07 UTC 1995

fgrep will only match patterns that are exact. It is fastest.
grep will match limited regular expressions, like the ones you use in
     matching file names. * matches anything, for example.
egrep is the extended one for serious matching, as Greg's example shows.
     Only the initiated usually know how to use it. * doesn't match anything,
     but rather it repeats the previous match indefinitely (as Greg said).
     egrep is the slowest. Valerie was probably thinking of fgrep.
(the above is my understanding, which is probably imperfect. please refine.)
gregc
response 41 of 111: Mark Unseen   Mar 18 08:45 UTC 1995

Sorry Steve, you didn't get it quite right. Yes, fgrep(which means fast grep)
will only search on exact strings. It doesn't support regexp. You got that
part right.

However, "*" means the same thing in grep and egrep.

I think I may have confused matters when I used the "ls" example above.
Filename wildcarding is done with a set of special characters that
is sometimes called "filename globbing". The rules for this bear an
only passing similarity to regexp. In filename globbing, "*" means
to match any number of chars, and "?" means to match only a single
character. This is completely different from regexp.

The difference between egrep and grep is that egrep supports *all* of
the regexp special characters and constructs, and grep supports a subset.
However, what constructs grep does implement, it implements in exactly
the same manner as egrep.

The example I gave in the earlier response, will work with both grep
and egrep.
rcurl
response 42 of 111: Mark Unseen   Mar 18 22:04 UTC 1995

One more (ir)relevant question. Why is this procedure called
"regular expression"?
robh
response 43 of 111: Mark Unseen   Mar 18 22:09 UTC 1995

Because it takes lots and lots of Ex-Lax?  >8)
rcurl
response 44 of 111: Mark Unseen   Mar 18 22:15 UTC 1995

Sounds logical - the man gave me constipation.
gregc
response 45 of 111: Mark Unseen   Mar 18 22:16 UTC 1995

Hmm, I'm afraid that one fits in the "fuck if I know" category.
popcorn
response 46 of 111: Mark Unseen   Mar 18 22:58 UTC 1995

This response has been erased.

srw
response 47 of 111: Mark Unseen   Mar 19 07:00 UTC 1995

Thanks for the correction Greg.

I am on firmer ground expounding the term "regular expression".
Regular expressions are a term from the domain of "formal languages".
This is a mathematical discipline really. This domain of math has
given us "regular expressions", "context-free grammars", 
BNF (Backus-Naur form), and many other topics that Computer Science
students often have to study and rarely perceive the utility of.

A regular expression is a formal way of representing some subset of the
strings that can be written in any alphabet. For example, a*bc*
is a regular expression that describes all strings that have a single b
which may be preceded by any number of a's and followed by any number of c's.

My, we must have drifted from the original topic.
nephi
response 48 of 111: Mark Unseen   Mar 19 07:07 UTC 1995

Should I edit this and post it to the info conference?
gregc
response 49 of 111: Mark Unseen   Mar 19 07:28 UTC 1995

Thanks for the Info Steve. That's interesting. I assumed it must be something
like that, but I had no idea where it came from. I'm reffering to RegExps.
I've never had any formal Computer Science training, so I have lots of
little gaps in my knowledge as to certain aspects of formalized CompSci.
 0-24   25-49   50-74   75-99   100-111      
Response Not Possible: You are Not Logged In
 

- Backtalk version 1.3.30 - Copyright 1996-2006, Jan Wolter and Steve Weiss