I would like to return the average of all numbers after a specific string in multiple files i.e.
We are given 10 files (file1.txt,...,file10.txt). Each file contains among others
Test1: Avg. length 24.01000, time: 0.579
Test2: Avg. length 22.02000, time: 0.879
with different numbers.
If we have 10 files it could look like
file1.txt
Test1: Avg. length 24.01000, time: 0.679
Test2: Avg. length 22.01000, time: 0.479
file2.txt
Test1: Avg. length 27.01000, time: 0.279
Test2: Avg. length 24.01000, time: 0.779
.....
file10.txt
The output I desire is the mean of the lengths and times of Test1 and Test2 over all files:
Mean Test1: Avg. length (file1_Test1_length+...+file10_Test1_lenght)/10, time (file1_Test1_time+...+file_10_Test1_time)/10
Mean Test2: Avg. length (file1_Test2_length+...+file10_Test2_lenght)/10, time (file1_Test2_time+...+file_10_Test2_time)/10
To grep the full output of Test1 I execute:
egrep -rh 'Test1: Avg. length.*' /home/timo/Documents
I'm not sure how to grep only the numbers. I tried
egrep -rhP '(?<=length )\d+' /home/timo/Documents
But I get an error
grep: conflicting matchers specified
I would be really thankful if someone could help me!