“ls” or regex is case insensitive

bashglobbingregex

In bash, I tried

ls [a-z]*

and expected to list all the files with filename starts with small case alphabet. But why the files with name starts with big case alphabet are also shown?

>ls [a-z]*
D  e
>

In case needed, the bash version:

bash –version
GNU bash, version 4.1.5(1)-release (i486-pc-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Best Answer

It's not regexp, which is where the confusion comes in. Instead, it uses a system called "globbing" - see:

$ man 7 glob

Instead of [a-z] you need to use [[:lower:]] as such:

$ ls -d [[:lower:]]*
Related Question