I set up a few files to understand bash's set construct wildcard, i.e. [].
ls *
1 2 A bob darlene dave ed frank fred LS_example.sh Z
The files I expected to be returned by ls [a-z]* would only include the ones beginning with a lower-case letter, but in the following, files beginning with an upper-case letter are also returned:
ls [a-z]*
A bob darlene dave ed frank fred LS_example.sh
Can you explain this behavior?
In your locale (and the way it's defined in your OS), [a-z] includes the upper and lower case letters. If you want to reliably match lowercase letters, do this:
ls [[:lower:]]*
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With