Print file in particular order in bash

前端 未结 6 412
谎友^
谎友^ 2021-01-13 13:22

I have file with content:

file.txt:

Iteration 1
RAM: +456ms
Cache: +142ms (total +417ms)

Iteration 2
Spec: +152ms
Cache: +149ms (total +413ms)

Iter         


        
6条回答
  •  太阳男子
    2021-01-13 13:44

    $ cat tst.awk
    BEGIN { FS="[: ]+" }
    /:/ { vals[$1] = vals[$1] OFS $2+0 }
    END { for (key in vals) print key vals[key] }
    
    $ awk -f tst.awk file
    Cache 142 149
    RAM 456 184 149
    Searchms 131 188
    Spec 152 172
    

提交回复
热议问题