When using character class in regexp it is case insensitive. I've tested this on several gentoo boxes and have the same result. sys-apps/grep-2.5.1a-r1 USE="nls pcre -static" Reproducible: Always Steps to Reproduce: Actual Results: $ echo Test | grep "^[a-z]" Test $ echo Test | grep -v "^[a-z]" $ echo test | grep "^[A-Z]" test $ echo test | grep -v "^[A-Z]" $ Expected Results: $ echo Test | grep "^[a-z]" $ echo Test | grep -v "^[a-z]" Test $ echo test | grep "^[A-Z]" $ echo test | grep -v "^[A-Z]" test
If you want a-z to match only lowercase characters, set LC_ALL to C. Your locale orders characters as aAbBcC...sStTuU...zZ (or as AaBbCc...SsTtUu...Zz, I suppose), where uppercase T is between lowercase a and lowercase z. This is the expected behaviour.
(In reply to comment #1) Yes, it helped. $ LC_ALL=C bash -c "echo abc | grep '[A-Z]'" $ LC_ALL=C bash -c "echo ABC | grep '[A-Z]'" ABC $ But why Debian whith ru_RU.UTF-8 locale doesn't have this issue?
You'd have to ask the Debian folks: Gentoo's grep is mostly identical to grep as released by GNU right now, there are just a few build fixes. Debian seems to have a collection of patches for it that may have changed its behaviour in this case.
I found an older bug. May be it should be fixed again? http://bugs.gentoo.org/show_bug.cgi?id=76192