On Sun, Apr 13, 2008 at 10:02 PM, Alex Samad <[EMAIL PROTECTED]> wrote: > On Sun, Apr 13, 2008 at 09:55:13PM +1000, Amos Shapira wrote: > > On Sun, Apr 13, 2008 at 9:41 AM, Alex Samad <[EMAIL PROTECTED]> wrote: > > > > Try grep -Ev '^(\W*;|$)' > > > great that works, (i changed to \s* instead, also tried the [[:space:]] > > > and it worked) > > > > > > I don't understand hwy i need to test for ^$, I had thought that once a > > > line test positive for ^\s*; it would be excluded ? > > > > Because empty lines do not match the '^\W*;' part (they don't have a > > ';' in them to match the regular expression) and so grep prints them. > > The '^$' part matches empty lines and so they are filtered out. > > but the line has already been matched why is it not discarded ?
Nope. The empty lines you see in the output (without the "^$" match) are empty lines from the original file (look them up), not lines which matched the ":" RE. When you look for empty lines in the input, be aware that there could be lines containing only white space, which won't match "^$" (to test, use "cat -e" on the file) but still look empty to "the naked eye", maybe you want you change that RE to something like: "^[:space:]*(;|$)" (i.e. match lines which begin with ";" (optionally preceded by white space) or which contain only zero or more white spaces). --Amos -- SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/ Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html
