С man bash
, тогда, если PAGER меньше / time
.
If the time reserved word precedes a pipeline, the elapsed as well as user and system time consumed by its exe-
cution are reported when the pipeline terminates. The -p option changes the output format to that specified by
POSIX. The TIMEFORMAT variable may be set to a format string that specifies how the timing information should
be displayed; see the description of TIMEFORMAT under Shell Variables below.
, тогда /TIMEFORMAT
The optional l specifies a longer format, including minutes, of the form MMmSS.FFs. The value of p
determines whether or not the fraction is included.
If this variable is not set, bash acts as if it had the value $'\nreal\t%3lR\nuser\t%3lU\nsys%3lS'. If
the value is null, no timing information is displayed. A trailing newline is added when the format
string is displayed.
Если его можно изменить на что-то вроде
TIMEFORMAT=$'\nreal\t%3R'
без l
, его будет проще суммировать.
Обратите внимание, что формат также может зависеть от локали LANG
:
сравнить
(LANG=fr_FR.UTF-8; time sleep 1)
и
(LANG=C; time sleep 1)
В этом случае сумму можно сделать с помощью внешнего инструмента, такого как awk
awk '/^real/ {sum+=$2} END{print sum} ' times.txt
илиPerl
perl -aln -e '$sum+=$F[1] if /^real/; END{print $sum}' times.txt