[英]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.