我很难理解这里发生了什么:
[guido@localhost 9]$ ls -1 Star\ Wars\ Episode\ *
Star Wars Episode II Attack of the Clones.avi
Star Wars Episode III Revenge of the Sith.avi
Star Wars Episode I The Phantom Menace.avi
Star Wars Episode IV A New Hope.avi
Star Wars Episode VI Return of the Jedi.avi
Star Wars Episode V The Empire Strikes Back.avi
Run Code Online (Sandbox Code Playgroud)
III\b
之前I\b
,但II\b
之前III\b
?无论是什么导致这种情况,它的行为都不一致。这也是我在 GUI 中得到的相同排序结果。我检查了所有空格实际上都是空格,文件名之间没有大小写差异。怎么会这样?它是否跳过了罗马数字,并试图在它之后进行排序?
其他测试:
[guido@localhost 9]$ find -name "Star Wars *" -print
./Star Wars Episode I The Phantom Menace.avi
./Star Wars Episode II Attack of the Clones.avi
./Star Wars Episode III Revenge of the Sith.avi
./Star Wars Episode IV A New Hope.avi
./Star Wars Episode V The Empire Strikes Back.avi
./Star Wars Episode VI Return of the Jedi.avi
Run Code Online (Sandbox Code Playgroud)
但:
[guido@localhost 9]$ find -name "Star Wars *" -print | sort
./Star Wars Episode II Attack of the Clones.avi
./Star Wars Episode III Revenge of the Sith.avi
./Star Wars Episode I The Phantom Menace.avi
./Star Wars Episode IV A New Hope.avi
./Star Wars Episode VI Return of the Jedi.avi
./Star Wars Episode V The Empire Strikes Back.avi
Run Code Online (Sandbox Code Playgroud)
尽管:
[guido@localhost 9]$ find -name "Star Wars *" -print | sort -f
./Star Wars Episode I The Phantom Menace.avi
./Star Wars Episode II Attack of the Clones.avi
./Star Wars Episode III Revenge of the Sith.avi
./Star Wars Episode IV A New Hope.avi
./Star Wars Episode V The Empire Strikes Back.avi
./Star Wars Episode VI Return of the Jedi.avi
Run Code Online (Sandbox Code Playgroud)
我不认为我的语言环境可能会影响这个(我也将它设置为 en_US.utf8 )正如文档所建议的那样。我错过了什么?
[guido@localhost 9]$ sort --version
sort (GNU coreutils) 8.22
Run Code Online (Sandbox Code Playgroud)