4wk*_*wk_ 3 unix sorting bash shell
sort工作怎么样?我有这个文件:
/test# cat foobar
html/lib/ORM/aaa.php
html/lib/ORMBase/ormbase_aaa.php
html/lib/ORM/zzz.php
html/lib/ORMBase/ormbase_zzz.php
Run Code Online (Sandbox Code Playgroud)
这是输出sort:
/test# cat foobar | sort
html/lib/ORM/aaa.php
html/lib/ORMBase/ormbase_aaa.php
html/lib/ORMBase/ormbase_zzz.php
html/lib/ORM/zzz.php
Run Code Online (Sandbox Code Playgroud)
我尝试了很多的选项:-f,-i,-t/...,我不明白这一点.我想理解为什么排序认为这是排序的.
注意:它适用于其他样本:
/test# cat foobar2
a/a/a
a/ab/a
a/ab/b
a/a/ab
a/abc/a
/test# cat foobar2 | sort
a/a/a
a/a/ab
a/ab/a
a/ab/b
a/abc/a
Run Code Online (Sandbox Code Playgroud)
sort试图在本地化方面聪明一点.它会忽略一些非字母数字字符等/.该手册页有一个简短的句子:
*警告*环境指定的区域设置会影响排序顺序.设置LC_ALL = C以获取使用本机字节值的传统排序顺序.
那么,要解决您的问题:
$ cat foobar | LC_ALL=C sort
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
401 次 |
| 最近记录: |