Alexey Vinogradov wrote: > ale...@ubuntu64:/tmp$ shopt -u nocaseglob; shopt -s nullglob; for a in > [B-C]* ; do echo $a; done
Since you do not mention your locale setting I assume that you are not aware of how it affects ranges. Here if your locale setting uses dictionary sort ordering then [B-C] is the same as [BcC]. $ echo b | env -i LC_ALL=en_US.UTF-8 grep '[B-C]' $ echo B | env -i LC_ALL=en_US.UTF-8 grep '[B-C]' B $ echo c | env -i LC_ALL=en_US.UTF-8 grep '[B-C]' c $ echo C | env -i LC_ALL=en_US.UTF-8 grep '[B-C]' C In the above you can see that lower case c exists in the range B-C but lower case b does not. In a locale that sets dictionary sort ordering the collating sequence is aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ. [a-z] is the same as [aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYz] [A-Z] is the same as [AbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ] You can read more about locales in the online standards documentation. http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html#tag_08_02 Personally I set the following in my ~/.bashrc file. export LANG=en_US.UTF-8 export LC_COLLATE=C Bob