[BASH]:元字符*返回增加字典顺序的结果?

[BASH]:元字符*返回增加字典顺序的结果?,bash,shell,trie,metacharacters,Bash,Shell,Trie,Metacharacters,请注意bash中的以下示例命令: jason@MacBook:~ mkdir temp jason@MacBook:~ cd temp jason@MacBook:~/temp touch file.txt jason@MacBook:~/temp touch file1.txt jason@MacBook:~/temp touch file2.txt jason@MacBook:~/temp ls file* file.txt file1.txt file2.txt jason@MacBoo

请注意bash中的以下示例命令:

jason@MacBook:~ mkdir temp
jason@MacBook:~ cd temp
jason@MacBook:~/temp touch file.txt
jason@MacBook:~/temp touch file1.txt
jason@MacBook:~/temp touch file2.txt
jason@MacBook:~/temp ls file*
file.txt  file1.txt file2.txt
jason@MacBook:~/temp touch file0.txt
jason@MacBook:~/temp ls file*
file.txt  file0.txt file1.txt file2.txt
jason@MacBook:~/temp touch fil.txt
jason@MacBook:~/temp ls fil*
fil.txt   file.txt  file0.txt file1.txt file2.txt
jason@MacBook:~/temp 
从输出中可以看到,所有文件名都按升序字典顺序排序


我想知道这是否是bash的一个需求,或者它是否是特定于实现的,而在我的Mac的bash shell中它恰好是这样工作的。我之所以这么问,是因为如果文件名存储在,代码中需要进行少量的调整才能正确地遍历trie,以按升序打印出文件名。

排序顺序——由
LC\u COLLATE
指定。顺便说一句,这个词是“glob expression”(允许更精确的标记/搜索/标题)。顺便说一句,引用自:“如果模式与任何现有文件名或路径名匹配,则应将模式替换为这些文件名和路径名,并根据当前语言环境中有效的排序顺序进行排序。”。如果模式包含无效的括号表达式或与任何现有文件名或路径名不匹配,则模式字符串应保持不变。“由于这是POSIX指定的行为,因此可以保证跨其他兼容shell(破折号、ksh)同样。另请参阅谢谢!对于可能感兴趣的人,此SO线程提供了有关LC_COLLATE的一些信息: