LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Problem with Globbing (https://www.linuxquestions.org/questions/linux-newbie-8/problem-with-globbing-4175663789/)

captain_john 11-06-2019 09:23 AM

Problem with Globbing
 
I created 2 files:
Code:

touch Test.txt test.txt
I can list the files:

Code:

ls -l
-rw------- 1 user users 20 Nov 6 test.txt
-rw------- 1 user users 20 Nov 6 Test.txt

However, globbing doesn't seem to work:

Code:

ls -l [a-z]*
-rw------- 1 user users 20 Nov 6 test.txt
-rw------- 1 user users 20 Nov 6 Test.txt

...but, using the macro, it works:

Code:

ls -l [[:lower:]]*
-rw------- 1 user users 20 Nov 6 test.txt


Thoughts?

pan64 11-06-2019 11:33 AM

Code:

user@host:/tmp/a$ touch Test.txt test.txt
user@host:/tmp/a$ ls -l
total 0
-rw-r--r-- 1 user group 0 Nov  6 18:31 test.txt
-rw-r--r-- 1 user group 0 Nov  6 18:31 Test.txt
user@host:/tmp/a$ ls -l [a-z]*
-rw-r--r-- 1 user group 0 Nov  6 18:31 test.txt
user@host:/tmp/a$ ls -l [[:lower:]]*
-rw-r--r-- 1 user group 0 Nov  6 18:31 test.txt
user@host:/tmp/a$

this works for me as expected
what kind of shell/os is it?
additionally would be nice to post not only parts of the result, but the full commands as I did it.

captain_john 11-06-2019 11:46 AM

Bash 4.2 on both Ubuntu 18.04 and CentOS

pan64 11-06-2019 12:16 PM

this is related to shopt nocaseglob and the variable LANG. see for example here: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=37971

captain_john 11-06-2019 12:59 PM

Yep! unset LANG results in desired behavior. Good catch!


All times are GMT -5. The time now is 02:02 PM.