Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is up with [A-Z] meaning [A-Za-z]?

I've noticed for a while now that, on some of the Unix-based systems I use at least, ls [A-Z]* has been giving me the results I would anticipate from ls [A-Za-z]*, leaving me unable to easily get a list of just the goddamned files that start with capital letters. I just now ran into the same thing with grep, where I could not get it to stop matching lowercase letters with [A-Z] until I eventually used grep -P to get Perl regex.

So I have some related questions:

  1. When did this idiocy start?
  2. Who is responsible and needs to be punished?
  3. WHY???
  4. Is there some reasonably simple workaround for either or both of the ls and grep cases? (Trying, for example, grep --no-ignore-case was fruitless. grep -P is not a very good workaround because of its experimental feature status.)
like image 320
chaos Avatar asked Jan 29 '11 00:01

chaos


1 Answers

It's actually [A-Za-y], and it has to do with language collation. If you want to override it then set $LC_COLLATE appropriately; either of C or POSIX should do.

like image 71
Ignacio Vazquez-Abrams Avatar answered Sep 28 '22 08:09

Ignacio Vazquez-Abrams