LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-02-2010, 10:36 PM   #1
e3399
Member
 
Registered: Nov 2010
Location: China
Distribution: Fedora12
Posts: 54

Rep: Reputation: 0
$ ll *[a-z]* I want to list files whose name contains at least one lower letter.


but why the file whose name contains no lower letters be listed too?
[test@localhost mytemp]$ ll *[a-z]*
-rw-rw-r--. 1 test test 0 2010-12-03 11:17 test1
-rw-rw-r--. 1 test test 0 2010-12-03 11:27 TEST1

Does [a-z] ignore case sensitivity?But linux does not ingore case sensitivity.
Any help will be appreciated!
 
Old 12-02-2010, 11:07 PM   #2
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
it's a locale thing.
Code:
[berhanie@host ~]$ ls
test1  TEST1
[berhanie@host ~]$ ls [a-z]*
test1  TEST1
[berhanie@host ~]$ ls [A-Z]*
test1  TEST1
[berhanie@host ~]$ export LC_ALL=C
[berhanie@host ~]$ ls [a-z]*
test1
[berhanie@host ~]$ ls [A-Z]*
TEST1
 
Old 12-03-2010, 08:58 AM   #3
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
Why is it that way?
 
Old 12-04-2010, 12:25 AM   #4
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
on my system, the LANG variable is set to en_US.UTF-8:
Code:
[berhanie@host ~]$ echo $LANG
en_US.UTF-8
since the LC_* environment variables are not set on my system, they inherit the value of LANG:
Code:
[berhanie@host ~]$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
in particular, LC_COLLATE, the variable used in sorting, inherits from LANG.
when LC_COLLATE == C, you get the expected behavior for ascii characters, i.e. they sort according to their byte value.
also, see http://www.madboa.com/geek/utf8/.
 
1 members found this post helpful.
Old 12-04-2010, 09:41 AM   #5
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
I understand that some people might like the new sorting order better for directory listings, but making [a-z] match uppercase letters seems just stupid.
 
Old 12-04-2010, 11:16 AM   #6
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
it's not that a smallcase letter matches a capital. it's just the collation that's different:
aAbBcCdD..zZ.
Code:
[berhanie@host ~]$ ls [t-z]*
test1  TEST1
[berhanie@host ~]$ ls [T-Z]* # this shows 't' comes before 'T'
TEST1
[berhanie@host ~]$ ls [t]*
test1
[berhanie@host ~]$ ls [T]*
TEST1

Last edited by Berhanie; 12-04-2010 at 11:17 AM.
 
Old 12-04-2010, 11:23 AM   #7
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
I get that. It's just that now, how can you posibly say "all lowercase letters"?
 
Old 12-04-2010, 11:27 AM   #8
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
you can use a character class:
Code:
[berhanie@host ~]$ ls
test1  TEST1  test2
[berhanie@host ~]$ ls [[:lower:]]*
test1  test2
 
1 members found this post helpful.
Old 12-07-2010, 02:26 AM   #9
e3399
Member
 
Registered: Nov 2010
Location: China
Distribution: Fedora12
Posts: 54

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Berhanie View Post
on my system, the LANG variable is set to en_US.UTF-8:
Code:
[berhanie@host ~]$ echo $LANG
en_US.UTF-8
since the LC_* environment variables are not set on my system, they inherit the value of LANG:
Code:
[berhanie@host ~]$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
in particular, LC_COLLATE, the variable used in sorting, inherits from LANG.
when LC_COLLATE == C, you get the expected behavior for ascii characters, i.e. they sort according to their byte value.
also, see http://www.madboa.com/geek/utf8/.
Berhanie,thanks for your help.
 
Old 12-07-2010, 08:32 AM   #10
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
Now mark the thread as solved.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need advice on a script to search many files for list of terms, append hits to list jimmy the saint Programming 1 07-11-2010 04:59 AM
Kate: Append files to existing list and enable the Recent List AGazzaz Linux - Software 2 10-13-2009 09:27 PM
Command to list files starting with uppercase letter djfog Linux - Newbie 5 07-04-2008 06:30 AM
script to list the filenames which are in lower case naveensankineni Programming 2 03-12-2008 08:09 AM
Lower case to upper case letter sudhasmyle Programming 1 12-03-2004 05:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration