[Novalug] need grep help

Jay Hart jhart at kevla.org
Fri Mar 16 17:06:45 EDT 2012


Ok, lets try a little, as we use to say in the Navy, "theory to damage".

----not a real line, filter starting next line
#FIRST line you should filter is this line
   #you should filter this line
you should not filter this line
   you should not filter this line
don't filter this line # cuz its not a comment
   or this line # as its not a comment

did you filter the above blank line
$this is a real line
   $this is also a real line, and is the LAST line
---end test, end filtering on above line

Copy just the test lines to a file and see how your filter works.  If you have
other example lines to try, add them, and then feed back your results to the
list.

It seems like this is something that a lot of us are looking for or currently
use.

Jay


> On 3/16/2012 4:29 PM, Kevin Cole wrote:
>>
>>
>> On Fri, Mar 16, 2012 at 16:20, John Holland <jbholland at gmail.com
>> <mailto:jbholland at gmail.com>> wrote:
>>
>>     The .* gets any characters after the first #. I think it is needed.
>>
>>
>> Why needed? I think JIM's right on this (at least in theory). I'm
>> wondering if I ran into some odd exception that would make his answer
>> wrong (unlikely) or if it was just a brain fart (highly likely).  Once
>> we've established that we've found a # either with whitespace before
>> it or not, we've established it's a comment, and can "junk it".  No
>> need to know about the characters after the first #.
> It's not needed for the # part...but if you don't see a # you have to
> make sure you don't see anything else either.
>
> In other words, it's necessary for the blank line part...the "^$" part.
>
> John...yes the alternation short circuits.
>
> Now that I think of it, perhaps this is best: "^[ \t]*(#|$)" in other words
>
> "Possible initial whitespace followed by either # or nothing else"
>
> I think we have a winner!
>
> JIM
> _______________________________________________
> Novalug mailing list
> Novalug at calypso.tux.org
> http://calypso.tux.org/mailman/listinfo/novalug
>




More information about the Novalug mailing list