简体   繁体   English

Linux可以对混合值列进行排序吗?

[英]Can Linux Sort sort mixed value columns?

I have a program that outputs something like this: 我有一个程序输出类似以下内容:

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

I want to sort by the third column so that the output looks like this: 我想按第三列排序,以便输出看起来像这样:

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

Is there a way to sort the third column so it will first sort by the first dimension in increasing order, then the second dimension in increasing order? 有没有一种方法可以对第三列进行排序,使其首先按第一维的升序排序,然后按第二维的升序排序? Incidentally the sort command I am using right now to get the results I am getting so far is: 顺便说一句,我现在正在使用的sort命令获取到目前为止得到的结果是:

sort -k2,2 -k1,1n -k3,3n

This should work for you 这应该为你工作

sort -tx -k1,1r file

I'm using x as the field delimiter 我正在使用x作为字段分隔符


PS: It does just work because 0: and test_func() appears on every line PS:它确实可以工作,因为0:test_func()出现在每一行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM