file globbing in now case insensitive?
Ralf Mardorf
silver.bullet at zoho.com
Sun Apr 2 15:56:29 UTC 2017
On Sun, 2 Apr 2017 10:12:32 -0400, Peter Silva wrote:
>After deleting a bunch of files by mistake, I've tried this on two
>different ubuntu 16.04's, and it works the same, but I don't
>understand why. Normally, file globbing is case sensitive. so:
>
>blacklab% mkdir /tmp/kk
>blacklab% cd /tmp/kk
>blacklab% ls
>blacklab% touch A b 1
>blacklab% ls -al
>total 1060
>drwxrwxr-x 2 peter peter 4096 Apr 2 10:08 .
>drwxrwxrwt 15 root root 1081344 Apr 2 10:08 ..
>-rw-rw-r-- 1 peter peter 0 Apr 2 10:08 1
>-rw-rw-r-- 1 peter peter 0 Apr 2 10:08 A
>-rw-rw-r-- 1 peter peter 0 Apr 2 10:08 b
>blacklab% echo [A-Z]*
>A b
>blacklab%
>
>Huh? this should only have listed A, but I got b as well...
> what's going on?
>
>blacklab% shopt | grep -i case
>nocaseglob off
>nocasematch off
>blacklab%
>
>I can't do case sensitive file globbing any more... no matter what
>settings are applied... this is overcoming how things have worked for
>30 years... what's going on?
[rocketmouse at archlinux test]$ ls
A b
[rocketmouse at archlinux test]$ echo [a-z]
A b
[rocketmouse at archlinux test]$ echo [[:lower:]]
b
"[snip]
@barlop: The behavior of character ranges depends on the locale,
specifically the LC_COLLATE setting In some (many?) locales, [a-z]
includes "aAbB...yYz" but not "Z". You can enable extended globbing
using shopt -s extglob. I get different results for [a-z] and
[[:lower:]] on Cygwin. – Dennis Williamson Mar 1 '11 at 14:44 add a
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:]]*
[snip]"
- https://superuser.com/questions/251777/ls-or-regex-is-case-insensitive
--
"Michael" described Floyd as "an idiot savant", and added, "Give him
any two numbers, and he can multiply them in his head, just like that."
Homer, testing Floyd, said, "Five times nine", and Floyd instantly
responded "Forty-five", which impressed Homer.
More information about the ubuntu-users
mailing list