Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9021911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:22:13+00:00 2026-06-16T05:22:13+00:00

I encountered the following IMHO strange behavior in bash’s file-patterns: $ ls Basic1 datei1

  • 0

I encountered the following IMHO strange behavior in bash’s file-patterns:

$ ls
Basic1  datei1  datie2  sdfl
$ ls [a-z]*
Basic1  datei1  datie2  sdfl
$ ls [abcdefghijklmnopqrstuvwxyz]*
datei1  datie2  sdfl

Why is the pattern with the range [a-z] not case-sensitive? Bug or feature?

Note:

  1. The bash-Option nocaseglob is off (otherwise, the second pattern given above should have also been case-insensitive…):

    $ shopt nocaseglob
    nocaseglob  off
    
  2. My bash-version:

    $ bash --version
    GNU bash, Version 4.2.24(1)-release (i686-pc-linux-gnu)
    

GNU bash, Version 4.2.24(1)-release (i686-pc-linux-gnu)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:22:14+00:00Added an answer on June 16, 2026 at 5:22 am

    If you only want file names that start with a lower-case, use

    ls [[:lower:]]*
    

    Edit

    Answering F. Hauri’s comment: section 3.5.8.1 of the reference manual says it all. But before we read it, let’s play a little bit (YMMV): create a new scratch directory and

    $ # Create lots of cool files
    $ touch {a..z} {A..Z}
    $ ls
    a  b  c  d  e  f  g  h  i  j  k  l  m  n  o  p  q  r  s  t  u  v  w  x  y  z
    A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X  Y  Z
    $ ls [a-b]
    a A b
    $ # Do you get it?
    $ ls [a-B]
    a A b B
    

    So it seems that bash’s alphabetical order (here, on my machine, with my settings) is:

    aAbBcCdDeE...
    

    This might explain why you got your results (it seems your settings are similar to mine).

    Now, go and read the section 3.5.8.1 of the reference manual and you’ll understand that things are not as simple, that the ordering depends on the value of the environment variable LC_COLLATE.

    So try:

    $ LC_COLLATE=C
    $ ls [a-b]
    a b
    

    Yeah!

    Moral

    If you want lower cases, don’t use [a-z] as this will highly depend on the local settings. Instead, use [[:lower:]]. In the reference manual, you’ll also find several other useful character classes.

    Bottom Line

    So, bug or feature? You now have the answer ;-)

    Hope this helps!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just encountered the following behavior: for (var i = 0; i < 50;
I encountered the following code in a file (looks like header file) iomanip of
I encountered following weird behavior yesterday. It seems a compiler bug to me or
I encountered the following code while looking up an example of the Observer pattern.
I encountered the following confusing problem: A DB table was updated through CSV file
I encountered the following exception earlier today: Unknown constant tag 32 in class file
I am in the process of changing my git-merge-workflow and encountered following problem: Up
I encountered the following problem after upgrading to the latest version 1.8.1 of data.table
I encountered the following error whilst running bundle install with ruby-debug19 in my Gemfile:
I encountered the following interview question on the Internet. Describe a data structure for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.