What is up with [A-Z] meaning [A-Za-z]?

后端 未结 3 601
暗喜
暗喜 2021-02-07 22:44

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-Z

3条回答
  •  故里飘歌
    2021-02-07 23:38

    It depends on your locale. If you want that [A..Z] only matches capital letters, you could use C locale: set LC_COLLATE or LC_ALL to C.

    LC_ALL=C
    ls [A..Z]*
    

    bash manual, pattern matching

提交回复
热议问题