[A-Z]表示[A-Za-z]的含义是什么? [英] What is up with [A-Z] meaning [A-Za-z]?
问题描述
我已经注意到一段时间了,在我至少使用的某些基于Unix的系统上,ls [A-Z]*
一直在给我我期望从ls [A-Za-z]*
获得的结果,这使我无法轻松获得仅以大写字母开头的该死的文件列表.我现在刚遇到grep
的问题,直到我最终使用grep -P
来获取Perl regex为止,我无法让它停止与[A-Z]
匹配小写字母.
I've noticed for a while now that, on some of the Unix-based systems I use at least, ls [A-Z]*
has been giving me the results I would anticipate from ls [A-Za-z]*
, leaving me unable to easily get a list of just the goddamned files that start with capital letters. I just now ran into the same thing with grep
, where I could not get it to stop matching lowercase letters with [A-Z]
until I eventually used grep -P
to get Perl regex.
所以我有一些相关的问题:
So I have some related questions:
- 这种蠢货是什么时候开始的?
- 谁负责并需要受到惩罚?
- 为什么?
- 对于
ls
和grep
情况中的一个或两个,是否有一些合理简单的解决方法? (例如,尝试grep --no-ignore-case
是徒劳的.grep -P
并不是很好的解决方法,因为它具有实验功能状态.)
- When did this idiocy start?
- Who is responsible and needs to be punished?
- WHY???
- Is there some reasonably simple workaround for either or both of the
ls
andgrep
cases? (Trying, for example,grep --no-ignore-case
was fruitless.grep -P
is not a very good workaround because of its experimental feature status.)
推荐答案
它实际上是[A-Za-y]
,它与语言整理有关.如果要覆盖它,则适当地设置$LC_COLLATE
;否则,请重新设置. C
或POSIX
都可以.
It's actually [A-Za-y]
, and it has to do with language collation. If you want to override it then set $LC_COLLATE
appropriately; either of C
or POSIX
should do.
这篇关于[A-Z]表示[A-Za-z]的含义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!