Michael C. Toren on 10 Nov 2003 22:22:02 -0500


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] regexp assistance please


On Mon, Nov 10, 2003 at 09:53:22PM -0500, Stephen Gran wrote:
> I am trying to write a regexp that lets me use grep (or really, egrep)
> to read a standard conffile-style file.  This means that I want to
> ignore any line that begins with a comment (for which I am currently
> only allowing the use of #), any line that is just a newline, and any
> line that is just whitespace (we don't need to worry about the
> possibility of multiline strings in this case).  I can come up with
> egrep -v '^#|^$' to ignore comments and _only_ newlines, but I would
> also like to ignore unseen whitespace (like \s*) - [:space:] just doesn't 
> seem to be working for me.  Can somebody whack me with a cluebat?

The "[:space:]" needs to occur within a character class, which
effectively requires the use of double square brackets.  Try:

	egrep -v '^[[:space:]]*(#|$)'

HTH,
-mct
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug