I have file with content:
file.txt:
Iteration 1
RAM: +456ms
Cache: +142ms (total +417ms)
Iteration 2
Spec: +152ms
Cache: +149ms (total +413ms)
Iter
One using awk:
$ awk '
$1 !~ /^(|First)$/ { # avoid forbidden keywords and empty lines
gsub(/[^0-9]/,"",$2) # remove non-numerals
a[$1]=a[$1] OFS $2 # append to associative array
}
END { # in the end
for(i in a) # loop all keywords
print i a[i] # output
}' file
Output lines in awk default order (appears random):
Cache: 142 149
Searchms: 131 188
Spec: 152 172
RAM: 456 184 149