[英]Can Linux Sort sort mixed value columns?
我有一个程序输出类似以下内容:
0: test_func() 4x1024 0.2260167
0: test_func() 4x128 0.020995
0: test_func() 4x2048 0.330319
0: test_func() 4x256 0.024929
0: test_func() 4x4096 1.329865
0: test_func() 4x512 0.056119
0: test_func() 4x64 0.004869
0: test_func() 4x8192 3.288312
0: test_func() 16x1024 0.778160
0: test_func() 16x128 0.084252
0: test_func() 16x2048 1.671658
0: test_func() 16x256 0.190282
0: test_func() 16x4096 5.664730
0: test_func() 16x512 0.312114
0: test_func() 16x64 0.036087
0: test_func() 16x8192 12.404933
1: test_func2() 4x64 0.004869
我想按第三列排序,以便输出看起来像这样:
0: test_func() 4x64 0.004869
0: test_func() 4x128 0.020995
0: test_func() 4x256 0.024929
0: test_func() 4x512 0.056119
0: test_func() 4x1024 0.226016
0: test_func() 4x2048 0.330319
0: test_func() 4x4096 1.329865
0: test_func() 4x8192 3.288312
0: test_func() 16x64 0.036087
0: test_func() 16x128 0.084252
0: test_func() 16x256 0.190282
0: test_func() 16x512 0.312114
0: test_func() 16x1024 0.778160
0: test_func() 16x2048 1.671658
0: test_func() 16x4096 5.664730
0: test_func() 16x8192 12.404933
1: test_func2() 4x64 0.004869
有没有一种方法可以对第三列进行排序,使其首先按第一维的升序排序,然后按第二维的升序排序? 顺便说一句,我现在正在使用的sort命令获取到目前为止得到的结果是:
sort -k2,2 -k1,1n -k3,3n
这应该为你工作
sort -tx -k1,1r file
我正在使用x
作为字段分隔符
PS:它确实可以工作,因为0:
和test_func()
出现在每一行
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.