I have output in a file that looks like this:  {tid=4, total=3, column.id=[5.0]}  {tid=2, total=1, column.id=[5.0]}{tid=5, total=8, column.id=[5.0]}{tid=8, total=6, column.id=[5.0]}elapsed time: 10 millisecondscurrent time: Thu Sep 15 16:15:30This set of output repeats multiple times with different elapsed times. I want to extract the integer representing elapsed time all the times it appears, and then find the average elapsed time. I believe I can get the elapsed time using awk but I am unsure of the correct syntax here.
Using awk to extract a value then perform a calculation
bash;ubuntu;awk
This should work assuming it's always in milliseconds.awk '/^elapsed time:/ {T+=$3;C++}; END {print T/C}' test.txt /^elapsed time:/ find lines matching desired pattern{T+=$3;C++}; add the third column in T up and count how many times we do it CEND {print T/C} print out our average.