Search code examples
bashglobcase-sensitive

unexplained linux case insensitivity in standard filename expansion


I do not understand. How is this matching?

$: shopt nocaseglob
nocaseglob      off
$: printf "%s\n" parser/*[a-z].jar
parser/parser-1.9.2.RELEASE.jar
parser/parser.jar

It's a VM in a cluster, not an emulation on a Windows machine.

$: cat /etc/centos-release
CentOS Linux release 7.6.1810 (Core)

I'm trying to do a simple case-sensitive match to exclude anything that isn't a lowercase alpha in front of .jar. I just want the version-anonymized symlinks for a loop, not the actual versioned files.


Solution

  • What [a-z] matches depends on the current locale. Under LC_COLLATE=C, [a-z] matches [abcdefghijklmnopqrtuvwxyz], but under some other settings, e.g. en_US, it matches [aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYz] - note that Z is not matched.