[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bug in grep with -i
From: |
Jon Tulk |
Subject: |
Bug in grep with -i |
Date: |
Tue, 15 Feb 2005 09:15:16 -0500 |
The -i flag in combination with case-sensitive symbols in a regular
expression gives incorrect results. I found this bug with the "\W"
symbol but have not tested any others.
Example:
grep -i "\WIL\W"
Expected behaviour is to find all lines containing "IL" (caseblind) as
a word. Actual result is to find all lines containing "IL" (caseblind)
only where embedded in a word.
From this result, I imply that the -i flag is causing the entire pattern
to be lower-cased prior to intrepretation of the "\W" symbol. The same
result is achieved by the command:
grep -i "\wil\w"
The examples below were run using the attached data file.
-bash-2.05b$ egrep "\WIL\W" sample
14 60970 IL WATSEKA
14 62868 IL NOBLE
-bash-2.05b$ egrep -i "\WIL\W" sample
4 72339 AR GILMORE
43 37237 TN NASHVILLE
44 75562 TX KILDARE
47 20142 VA ROUND HILL
49 24842 WV HEMPHILL
-bash-2.05b$ egrep -i "\wil\w" sample
4 72339 AR GILMORE
43 37237 TN NASHVILLE
44 75562 TX KILDARE
47 20142 VA ROUND HILL
49 24842 WV HEMPHILL
-bash-2.05b$ grep -V
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.
This is running on Red Hat Advanced Server 3.0
I hope I'm not wasting your time on a duplicate. I couldn't find this one
in your archives.
Regards,
Jon Tulk
sample
Description: Text document
- Bug in grep with -i,
Jon Tulk <=