The bash expansion seems to ignore capitals.
(similary for ls [a-b]* )
How do I get bash to respect the case in its expansion?
The bash expansion seems to ignore capitals.
(similary for ls [a-b]* )
How do I get bash to respect the case in its expansion?
On Tue, 23 Jun 2020 21:35:54 -0400, William Unruh <unruh@invalid.ca> wrote:listed.
The bash expansion seems to ignore capitals.
(similary for ls [a-b]* )
How do I get bash to respect the case in its expansion?
LC_ALL=C ls [a-b]*
That's from the Pattern Matching section of man bash.
Note that if a directory starts with a or b, it's full contents will be
Regards, Dave Hodgins
On 2020-06-24, David W. Hodgins <dwhodgins@nomail.afraid.org> wrote:
On Tue, 23 Jun 2020 21:35:54 -0400, William Unruh
<unruh@invalid.ca> wrote:=20
The bash expansion seems to ignore capitals.
(similary for ls [a-b]* )
How do I get bash to respect the case in its expansion? =20
LC_ALL=3DC ls [a-b]*=20
That's from the Pattern Matching section of man bash.
Note that if a directory starts with a or b, it's full contents
will be listed. =20
Thanks.
My LC_ALL is en_CA.UTF-8. But how in the world does
en_CA.UTF-8 make a, b occur between A and B? Certainly it distingushes between a and A and ls [a]* -d does not list files starting with A.
On 24.06.2020 at 15:48, William Unruh scribbled:
On 2020-06-24, David W. Hodgins <dwhodgins@nomail.afraid.org> wrote:
On Tue, 23 Jun 2020 21:35:54 -0400, William Unruh
<unruh@invalid.ca> wrote:
The bash expansion seems to ignore capitals.
(similary for ls [a-b]* )
How do I get bash to respect the case in its expansion?
LC_ALL=C ls [a-b]*
That's from the Pattern Matching section of man bash.
Note that if a directory starts with a or b, it's full contents
will be listed.
Thanks.
My LC_ALL is en_CA.UTF-8. But how in the world does
en_CA.UTF-8 make a, b occur between A and B? Certainly it distingushes
between a and A and ls [a]* -d does not list files starting with A.
It's actually LC_COLLATE which does that. Insofar I know, every locale
mixes upper- and lowercase for sorting, and only LC_COLLATE=C sorts
uppercase first and lowercase after that — or vice versa; I don't
remember.
By the way, LC_ALL, when set, overrides all other LC_* variables. So
for instance, if you have LC_TIME set to "en_CA.UTF-8" and LC_ALL to
"C", then all of your locale settings are effectively set to "C", even
though the variables themselves are not altered.
But this is different. It is not only sorting them mixed up but is also finding them is caseless. [a]* finds only files that start with a, but [A-B]* finds files which start with A, a, B, b. That is independent of sorting.
On Wed, 24 Jun 2020 19:05:48 -0400, William Unruh <unruh@invalid.ca> wrote:treated
But this is different. It is not only sorting them mixed up but is also
finding them is caseless. [a]* finds only files that start with a, but
[A-B]* finds files which start with A, a, B, b. That is independent of
sorting.
https://en.wikipedia.org/wiki/Unicode_collation_algorithm
It ignores case and accents when sorting so that a, A, à, À, etc are all
as being the same.
When you have [a]*, the square brackets are ignored since it isn't a range being selected.
Regards, Dave Hodgins
But as I said, it is not sorting. It is selecting.
Since a* is different from A* the selection algorithm clearly treats A
and a differently.
On Thu, 25 Jun 2020 05:06:17 -0000 (UTC), William Unruh wrote:
But as I said, it is not sorting. It is selecting.
Since a* is different from A* the selection algorithm clearly treats A
and a differently.
Sound about right. [a-z] selects only lowercase.
See up thread for my suggestion.
ls -d [a-b]*.......
env|grep LC_LC_ALL=en_CA.UTF-8
LC_COLLATE=C env|grep LC_LC_COLLATE=C
LC_COLLATE=C ls -d [a-b]*.......
On 2020-06-25, Bit Twister <BitTwister@mouse-potato.com> wrote:
On Thu, 25 Jun 2020 05:06:17 -0000 (UTC), William Unruh wrote:
But as I said, it is not sorting. It is selecting.
Since a* is different from A* the selection algorithm clearly treats A
and a differently.
Sound about right. [a-z] selects only lowercase.
See up thread for my suggestion.
Nope
ls -d [a-b]*
On 2020-06-25, Bit Twister <BitTwister@mouse-potato.com> wrote:
On Thu, 25 Jun 2020 05:06:17 -0000 (UTC), William Unruh wrote:
But as I said, it is not sorting. It is selecting.
Since a* is different from A* the selection algorithm clearly treats A
and a differently.
Sound about right. [a-z] selects only lowercase.
See up thread for my suggestion.
Nope
ls -d [a-b]*......
BillUnruhPortfolioReview23Mar20-altered.pdf
Bill.zip
bin/
binarypulsar-Sci
----
env|grep LC_LC_ALL=en_CA.UTF-8
LC_SOURCED=1
LC_CTYPE=C
LC_COLLATE=C env|grep LC_LC_COLLATE=C
LC_ALL=en_CA.UTF-8
LC_SOURCED=1
LC_CTYPE=C
LC_COLLATE=C ls -d [a-b]*......
BillUnruhPortfolioReview23Mar20-altered.pdf
Bill.zip
bin/
binarypulsar-Sci
----
On Thu, 25 Jun 2020 14:32:12 -0000 (UTC), William Unruh wrote:
On 2020-06-25, Bit Twister <BitTwister@mouse-potato.com> wrote:
On Thu, 25 Jun 2020 05:06:17 -0000 (UTC), William Unruh wrote:
But as I said, it is not sorting. It is selecting.
Since a* is different from A* the selection algorithm clearly treats A >>>> and a differently.
Sound about right. [a-z] selects only lowercase.
See up thread for my suggestion.
Nope
ls -d [a-b]*
One more time [a-b] indicates lowercase only.
I can suggest reading the following page very carefully. https://www.regular-expressions.info/posixbrackets.html
On 2020-06-25, Bit Twister <BitTwister@mouse-potato.com> wrote:
On Thu, 25 Jun 2020 05:06:17 -0000 (UTC), William Unruh wrote:
But as I said, it is not sorting. It is selecting.
Since a* is different from A* the selection algorithm clearly
treats A and a differently.
Sound about right. [a-z] selects only lowercase.
See up thread for my suggestion.
Nope
ls -d [a-b]*......
BillUnruhPortfolioReview23Mar20-altered.pdf
Bill.zip
bin/
binarypulsar-Sci
----
env|grep LC_LC_ALL=en_CA.UTF-8
LC_SOURCED=1
LC_CTYPE=C
LC_COLLATE=C env|grep LC_LC_COLLATE=C
LC_ALL=en_CA.UTF-8
LC_SOURCED=1
LC_CTYPE=C
LC_COLLATE=C ls -d [a-b]*......
BillUnruhPortfolioReview23Mar20-altered.pdf
Bill.zip
bin/
binarypulsar-Sci
----
On 25.06.2020 at 14:32, William Unruh scribbled:
On 2020-06-25, Bit Twister <BitTwister@mouse-potato.com> wrote:
On Thu, 25 Jun 2020 05:06:17 -0000 (UTC), William Unruh wrote:
But as I said, it is not sorting. It is selecting.
Since a* is different from A* the selection algorithm clearly
treats A and a differently.
Sound about right. [a-z] selects only lowercase.
See up thread for my suggestion.
Nope
ls -d [a-b]*......
BillUnruhPortfolioReview23Mar20-altered.pdf
Bill.zip
bin/
binarypulsar-Sci
----
env|grep LC_LC_ALL=en_CA.UTF-8
LC_SOURCED=1
LC_CTYPE=C
LC_COLLATE=C env|grep LC_LC_COLLATE=C
LC_ALL=en_CA.UTF-8
LC_SOURCED=1
LC_CTYPE=C
LC_COLLATE=C ls -d [a-b]*......
BillUnruhPortfolioReview23Mar20-altered.pdf
Bill.zip
bin/
binarypulsar-Sci
----
As I wrote already, Bill, LC_ALL overides all other LC_* settings.
You have your LC_ALL set to "en_CA.UTF-8". By consequence, your "LC_COLLATE=C" has no effect.
On 2020-06-25, Bit Twister <BitTwister@mouse-potato.com> wrote:
On Thu, 25 Jun 2020 14:32:12 -0000 (UTC), William Unruh wrote:
On 2020-06-25, Bit Twister <BitTwister@mouse-potato.com> wrote:
On Thu, 25 Jun 2020 05:06:17 -0000 (UTC), William Unruh wrote:
But as I said, it is not sorting. It is selecting.
Since a* is different from A* the selection algorithm clearly treats A >>>>> and a differently.
Sound about right. [a-z] selects only lowercase.
See up thread for my suggestion.
Nope
ls -d [a-b]*
One more time [a-b] indicates lowercase only.
One more time. I gave you the evidence. It does not.
I have now run the experiment many times. It choses both
lower and upper case if LC_ALL is en_CA.UTF-8
I can suggest reading the following page very carefully.
https://www.regular-expressions.info/posixbrackets.html
globbing is not a regular expression.
I do experiments in this case, not theory.
What is your value of LC_ALL?
What do you get if you do
ls [a-b]* -d
?
(assuming that you have a mixture of lower and upper case file names)
Reding the bash man page again, I noticed the globasciiranges option.
Do you have the shell option globasciranges set?
shopt globasciiranges
is that on or off? Mine was off.
I have now put
shopt -s globasciiranges
into .bashrc, and the ranges behave properly, as expected, even with
LC_ALL not being C.
While that may be true, I can also do
LC_ALL='' LC_COLLATE=C ls [a-b]* -d
Now those capital B filenames are still selected, but they now are
listed at the beginning of the list of files, instead of interspersed
with the lower case b file.
Ie, the LC_ALL does not determine bash glob per se.
(except of course LC_ALL=C does).
shopt -s globasciiasciiranges
does work independent of the setting of LC_ALL.
LC_COLLATE does not determine the selection process for those ranges.
LC_ALL does, but I cannot see any specific LC_XXX which does control
it. Very strange.
On 25.06.2020 at 17:22, William Unruh scribbled:
While that may be true, I can also do
LC_ALL='' LC_COLLATE=C ls [a-b]* -d
Now those capital B filenames are still selected, but they now are
listed at the beginning of the list of files, instead of interspersed
with the lower case b file.
Ie, the LC_ALL does not determine bash glob per se.
(except of course LC_ALL=C does).
shopt -s globasciiasciiranges
does work independent of the setting of LC_ALL.
LC_COLLATE does not determine the selection process for those ranges.
LC_ALL does, but I cannot see any specific LC_XXX which does control
it. Very strange.
But, you forgot the number-one rule... The shell always globs BEFORE processing anything else. So the "*" in your command was already
globbed BEFORE the "[a-b]" was.
On Thu, 25 Jun 2020 16:43:23 -0000 (UTC), William Unruh wrote:
On 2020-06-25, Bit Twister <BitTwister@mouse-potato.com> wrote:
On Thu, 25 Jun 2020 14:32:12 -0000 (UTC), William Unruh wrote:
On 2020-06-25, Bit Twister <BitTwister@mouse-potato.com> wrote:
On Thu, 25 Jun 2020 05:06:17 -0000 (UTC), William Unruh wrote:
But as I said, it is not sorting. It is selecting.
Since a* is different from A* the selection algorithm clearly treats A >>>>>> and a differently.
Sound about right. [a-z] selects only lowercase.
See up thread for my suggestion.
Nope
ls -d [a-b]*
One more time [a-b] indicates lowercase only.
One more time. I gave you the evidence. It does not.
And yet, it is working as you directed it to do so.
NOT like you wanted. You tell it you want Uppercase and see what happens.
range.I have now run the experiment many times. It choses both
lower and upper case if LC_ALL is en_CA.UTF-8
I can suggest reading the following page very carefully.
https://www.regular-expressions.info/posixbrackets.html
globbing is not a regular expression.
I do experiments in this case, not theory.
Screw theory. I am trying to get you to read how your brackets are working. Apparently you are not going to do so. :(
What is your value of LC_ALL?
I always try to work with defaults wherever possible.
$ env | grep LC_
LC_SOURCED=1
What do you get if you do
ls [a-b]* -d
?
(assuming that you have a mixture of lower and upper case file names)
As indicated I get any file name with a lower case letter in the a to b
Adding uppercase A and B to the range gets me the files with uppercase A toB range.
$ ls
a1.a a.a a.A A.a b.b B.B
$ ls [a-b]*
a1.a a.a a.A A.a b.b
$ ls [a-bA-B]*
a1.a a.a a.A A.a b.b B.B
Reding the bash man page again, I noticed the globasciiranges option.
Do you have the shell option globasciranges set?
shopt globasciiranges
is that on or off? Mine was off.
Same here.
I have now put
shopt -s globasciiranges
into .bashrc, and the ranges behave properly, as expected, even with
LC_ALL not being C.
I do not. As I indicated I get the same as if I did [abB]*
$ env | grep utf
LANG=en_US.utf8
LANGUAGE=en_US.UTF-8:en_US:en
LESSCHARSET=utf-8
XTERM_LOCALE=en_US.utf8
$ echo $TERM
xterm
On 26/6/20 10:25 am, Bit Twister wrote:
$ env | grep utf
LANG=en_US.utf8
LANGUAGE=en_US.UTF-8:en_US:en
LESSCHARSET=utf-8
XTERM_LOCALE=en_US.utf8
$ echo $TERM
xterm
Curiously I require "-i" to be stated.
Do you have it set globally?
[faeychild@unimatrix ~]$ env | grep -i utf
LC_MEASUREMENT=en_AU.UTF-8
LANG=en_AU.UTF-8
LC_TIME=en_AU.UTF-8
[faeychild@unimatrix ~]$ env | grep utf
[faeychild@unimatrix ~]$
Sorry about that. Yes I do. Same for locate.
$ type grep
grep is aliased to `grep --color --ignore-case'
$ type locate
locate is aliased to `locate --ignore-case'
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 482 |
Nodes: | 16 (2 / 14) |
Uptime: | 64:11:54 |
Calls: | 9,569 |
Files: | 13,663 |
Messages: | 6,143,739 |