LinuxQuestions.org
Review your favorite Linux distribution.
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 09-02-2008, 10:10 PM   #1
trrose
LQ Newbie
 
Registered: Sep 2008
Posts: 2

Rep: Reputation: 0
Question ls -d [a-z]* displays same as ls -d [A-Z]*


According to General Linux I (Exam Cram) by Dulaney pg 17, ls -d [a-z]* should only display files that begin with a lowercase letter. I've also tried [A-Z] as you can see. According to Dulaney they should behave differently given the files I'm trying to list but they don't.


----------------
$ ls -d [A-Z]*
Desktop DIR_COLORS Documents Junk JUNK junk1 Music Pictures Public Templates Videos

$ ls -d [a-z]*
Desktop DIR_COLORS Documents Junk JUNK junk1 Music Pictures Public Templates Videos
----------------


As a side note, is the Dulaney book helpful in passing the LPI Gen. Lin. 101 exam? I've been using Linux at home for years and am fairly familiar with bash which I'm using now.
Regards, Tom
p.s. Great site! I just signed up.
 
Old 09-03-2008, 12:36 AM   #2
drewbug01
Member
 
Registered: Aug 2006
Location: Detroit!
Distribution: Ubuntu 7.04
Posts: 182

Rep: Reputation: 30
Same results on my machine, when running BASH:
Code:
andrew@the-haystack:~$ ls -d [a-z]*
Desktop    Examples                Music  Pictures  test1  Videos
Documents  gtk-gnutella-downloads  PDF    storage   test2
andrew@the-haystack:~$
Notice the different results when I simply run sh, not bash:
Code:
$ ls -d [a-z]*
gtk-gnutella-downloads  storage  test1  test2
$ ls -d [A-Z]*
Desktop  Documents  Examples  Music  PDF  Pictures  Videos
Hope this helps!
 
Old 09-03-2008, 01:04 AM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Notice that sensible distributions like Slackware (using bash)
also give the correct result ...
Code:
$ echo $SHELL
/bin/bash
$ ls
AAA  aaaa  BBB  bbbb  CCC  cccc
$ ls -d [a-z]*
aaaa  bbbb  cccc
$ ls -d [A-Z]*
AAA  BBB  CCC

So that faulty output is not a bash, but a Ubuntu feature.

I'd be looking at my initialisation scripts, and ~/.bashrc
and/or ~/.bash_{profile|login}




Cheers,
Tink
 
Old 09-03-2008, 01:09 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,357

Rep: Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367
"The asterisk -- * -- matches any number of repeats of the character string or RE preceding it, including zero(!) instances."

That's my exclamation mark

from http://www.tldp.org/LDP/abs/html/x16044.html
 
Old 09-03-2008, 01:18 AM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally Posted by chrism01 View Post
"The asterisk -- * -- matches any number of repeats of the character string or RE preceding it, including zero(!) instances."

That's my exclamation mark :)

from http://www.tldp.org/LDP/abs/html/x16044.html
But in the case of
Code:
ls -ld [A-Z]*
there's no regex, it's shell-globbing. And it
means any capital letter followed by anything
else (or nothing).


Cheers,
Tink
 
Old 09-03-2008, 01:32 AM   #6
drewbug01
Member
 
Registered: Aug 2006
Location: Detroit!
Distribution: Ubuntu 7.04
Posts: 182

Rep: Reputation: 30
Hmmm.....

Created a test account, blasted away the .bashrc file, and still same results.
[code]test@the-haystack:~$ ls -l .bashrc
-rw-r--r-- 1 test test 1 2008-09-03 02:30 .bashrc
test@the-haystack:~$ mkdir test TEST
test@the-haystack:~$ ls
Examples test TEST
test@the-haystack:~$ ls -d [a-z]*
Examples test TEST
 
Old 09-03-2008, 02:10 AM   #7
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
There are some shopt settings for case sensitivity in glob patterns, nocaseglob and nocasematch. For some reason on Ubuntu, these have no impact on the OP's command... Looks like an Ubuntu bug to me.
 
Old 09-03-2008, 03:11 AM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,357

Rep: Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367
See also answer to E9 here: http://www.faqs.org/faqs/unix-faq/shell/bash/ . Appears to be locale dependent.
 
Old 09-03-2008, 07:53 PM   #9
trrose
LQ Newbie
 
Registered: Sep 2008
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks to all of you. I read every word. Hey Chris, thanks alot for the link to gnu.bash.bug. I guess it's logical but unconventional, I think. However, perhaps it's conventional among programmers. That question is an interesting departure point on human communication and how we change registers (Linguistic term I think) depending on the group we're communicating with at the moment.
Regards, Tom
 
Old 09-03-2008, 08:24 PM   #10
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,357

Rep: Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367
Actually, having tested your prob in my system, even after having reset lang to en_GB, still had same prob. (my post #8)

Set this

export LC_COLLATE=C

in my /etc/profile and its all good now ie distinguishes between case.
(have to completely logout/in for it to take effect).
 
Old 09-03-2008, 08:26 PM   #11
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally Posted by chrism01 View Post
See also answer to E9 here: http://www.faqs.org/faqs/unix-faq/shell/bash/ . Appears to be locale dependent.
And confirming that one ...

My default locale settings (specifically LANG) are
en_US (with LC_COLLATE=C), and the "normal" behaviour
occurs. I've also checked on a machine running SLED
with LANG=POSIX and LC_CTYPE=en_US.UTF-8 being the only
locale relevant settings, same thing. On an Ubuntu box,
as soon as I set LANG=POSIX, ls output becomes "normal"
(in other words as I've been used to for the last 11
years ;D) ... won't spend much time on researching it
further, though.


Cheers,
Tink
 
  


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
Dual monitors, separate X displays; want firefox in both displays bforbes Linux - Desktop 7 10-15-2008 09:26 PM
out X on several remote displays abd_bela Debian 1 06-27-2008 04:38 PM
Dual Displays systemparadox Linux - Hardware 5 02-16-2006 03:34 PM
How to get the x displays currently open? 95se Linux - General 3 09-11-2004 11:11 AM
Dual Displays p0rt Linux - General 2 06-25-2003 01:36 PM


All times are GMT -5. The time now is 01:52 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