On 9/3/2024 9:13 AM, Rich Draves via Cygwin wrote:

I often use grep -r --include. But it has a really annoying problem - the
comparison of the filename is case-sensitive. The -i option seems to apply
only to the regex not the filename matching.

For example, I have many files named virtualenvironment.ini. But
unfortunately, sometimes it is virtualEnvironment.ini,
VirtualEnvironment.ini, etc.

Grep -r --include=virtualenvironment.ini skips the latter files. As a
work-around, I use --include="[Vv]irtual[Ee]nvironment.ini" but this is
cumbersome and not a complete solution.

Because Windows is case-insensitive/case-preserving, I think the Cygwin
filename matching should also be case-insensitive. Am I missing something
here?

Maybe ... Cygwin is trying to act as closely as possible to Posix behavior as
it can when running under Windows.  AFAIK, Posix does not offer
case-insensitive filename matching for grep.  While it's more cumbersome,
depending on the filenames you desire to match against, you could do something
like:

grep your-regex $(find . -iname 'virtualenvironment.ini')

The -iname operator of find asks it to do a case-insensitive filename match.
See also its -ipath and -iregex operators.

Regards - Eliot Moss

--
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to