for i in {1..10}; do time some_script.sh; done 2>&1 | grep ^real | sed -e s/.*m// | awk '{sum += $1} END {print sum / NR}'
time
time
so we can grep itgrep ^real
is to get only the lines starting with "real" in the output of time
time
)NR
)The snippet assumes that the running time of some_script.sh is less than 1 minute, otherwise it won't work at all.
Depending on your system, the time
builtin might work differently.
Another alternative is to use the time command /usr/bin/time instead of the bash builtin.