Matthew Woehlke wrote:
grendelos wrote:
So this is really bugging me. Why is [a-z] not case sensitive, but
[A-Z] is? For example:
# ls -l
total 0
-rw-r--r-- 1 root root 0 Nov 20 12:22 xa
-rw-r--r-- 1 root root 0 Nov 20 12:22 xA
# ls -l x[a-z]
-rw-r--r-- 1 root root 0 Nov 20 12:22 xa
-rw-r--r-- 1 root root 0 Nov 20 12:22 xA
# ls -l x[A-Z]
-rw-r--r-- 1 root root 0 Nov 20 12:22 xA
Any ideas?
Yes. Your assumptions are wrong.
[a-z] = [aAbBcCdD...xXyYz]
[A-Z] = [AbBcCdDe...XyYzZ]
Oops, and I should have added that this depends on the locale. Very
likely it is correct in this instance (perhaps omitting vowels with
accents/etc that might also be in the set). But hopefully the idea -
i.e. that the range '[a-z]' includes 'A' but not 'Z', and that '[A-Z]'
includes 'z' but not 'a' - is clear.
Now... see why that gives the results you are seeing?
This is FAQ #1 regarding locales (sorry, no links handy, but GIYF). If
you want the expected (case-sensitive) behavior, try 'export LC_ALL=C'.
--
Matthew
Please do not quote my e-mail address unobfuscated in message bodies.
--
C++ is for people who want to be able to not just shoot themselves in
the foot, but do it with a rocket launcher. -- Igor Peshansky