bug-grep
[Top][All Lists]
Advanced

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

Re: Problem with regular expression using grep -E


From: Joey Officer
Subject: Re: Problem with regular expression using grep -E
Date: Thu, 5 Jul 2007 15:00:35 -0500

Upon closer investigation of the string I am searching for, I believe I have
found the error, but am unsure on how to correct this issue.  In the third
regex sting, I am searching for 10.61.98.0 through 63.  In my example,
10.61.98.23 retrieves log lines with reference to 10.61.98.23(?), so .23 &
.230 & .231 & .232 etc...

Is there a way to match the exact expression, nothing more so return
10.61.98.23 but NOT 10.61.98.23(x) where x = 0 through 9.  The same would
need to apply to expressions .24 and .25 and for that matter .11 but not
.110 or .111 etc...

Is this possible?

On 7/5/07, Joey Officer <address@hidden> wrote:

I think I have found a bug in grep's usage of regular expressions, or
possibly an error in my regular expression although I have checked and
rechecked my expression.

I process the following command:

zcat -c logfile.gz | grep -E -f searchIP.txt >> filteredIPs.log

searchIP.txt:
10\.61\.98\.(6[4-9]|[7-9][0-9]|1([0-1][0-9]|2[0-7]))
10\.61\.97\.([0-9]|[1-9][0-9]|1([0-9][0-9])|2([0-4][0-9]|5[0-5]))
10\.61\.98\.([0-9]|[1-5][0-9]|6[0-3])

the above regular expression should return all IP ranges for 10.61.98.64through
10.61.98.127 (line1) 10.61.97.0 through 10.61.97.255 (line2) and
10.61.98.0 through 10.61.98.0 through 10.61.98.63 (line3).

When I review the results of filteredIPs.log I see IP address that fall
outside of those ranges.  For example, I see 10.61.98.230 listed in the
result sets, which should be excluded.

The following may or may not be useful information:

$ uname -a
CYGWIN_NT-5.2 bkfnocbcr1 1.5.24(0.156/4/2) 2007-01-31 10:57 i686 Cygwin

$ grep --version
grep (GNU grep) 2.5.1

Copyright 1988, 1992-1999, 2000, 2001 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

$ zcat --version
gzip 1.3.12
Copyright (C) 2007 Free Software Foundation, Inc.
Copyright (C) 1993 Jean-loup Gailly.
This is free software.  You may redistribute copies of it under the terms
of
the GNU General Public License <http://www.gnu.org/licenses/gpl.html >.
There is NO WARRANTY, to the extent permitted by law.

Written by Jean-loup Gailly.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]