[PLUG] simple grep/regex question

Galen Seitz galens at seitzassoc.com
Mon Apr 14 19:08:19 UTC 2008


Jeme A Brelin wrote:
> On Mon, 14 Apr 2008, Galen Seitz wrote:
>> I've tried these:
>>  grep '[^;]*bit' foo.asm   # matches all bit
> 
> That's because the "bit" is preceeded by one or more non-; characters.
> 
> Make sure you match the start of the line in your regex and you're good:
> 
> grep "^[^;]*bit" foo.asm  # matches what you need!
> 

Thanks!  So simple, and yet I wasn't seeing the problem.  Now I can do 
what I really want, which is catching bit0-bit19.

grep -i '^[^;]*bit1*[0-9]' *.asm


Paul Heinlein wrote:
> Would it ever happen that 'bit' could appear multiple times on a 
> single line, both in the code and in the comments?
> 

Yes.  I think the regex above meets my needs.


galen



More information about the PLUG mailing list