I have file with content:
file.txt:
Iteration 1 RAM: +456ms Cache: +142ms (total +417ms) Iteration 2 Spec: +152ms Cache: +149ms (total +413ms) Iter
Simply:
#!/bin/bash for i in RAM Cache Spec Searchms; do echo "$i `cat file.txt | grep $i | grep -Eo '[0-9]{1,9}' | tr '\n' ' '`" >> out.txt done
You can change the order in line 2 ( for loop )
Output:
$ cat out.txt RAM 456 184 149 Cache 142 417 149 413 Spec 152 172 Searchms 131 385 188