Puzzled by A Regexp...

Tres Hofmeister tres at virga.rap.ucar.edu
Tue Mar 5 07:15:51 AEST 1991


	I've run across a regular expression that I don't quite understand.
Not that this hasn't happened before, but this seems like it should be
fairly straightforward...

	I'm trying to match entries in /etc/group which have one or more
members.  The following works just fine, matching each of the colon
delimited fields individually followed by one or more characters:

	grep '^.*:.*:.*:..*' /etc/group

	What I don't understand is why the following doesn't work the same
way:

	grep '^.*:..*' /etc/group

	It grabs entries with one or more members, true, but also grabs
entries with no members, e.g. "news:*:6:".  I figured that this regexp
would match the longest possible string at the beginning of a line,
terminated by a colon, which in the group file should include the first
two colons, followed by at least one character.  It seems to be doing
something else, given that it will also match a line with no members.

	Any ideas?


Tres Hofmeister
tres at ncar.ucar.edu
--
Tres Hofmeister
tres at ncar.ucar.edu



More information about the Comp.unix.shell mailing list