用于跟踪运行时的可读输出

时间:2013-12-05 12:53:30

标签: bash time format

我希望使用/usr/bin/time和我尝试类似

时的输出样式
/usr/bin/time -f'time=%E' ls > /dev/null

输出

time=0:00.05

5 表示 5厘秒

如果我的命令/脚本运行的时间较长,则输出将为例如:

time=1:30:05

5 表示 5秒

我希望将输出写在man time

   The format string
       The format is interpreted in the usual printf-like way.  Ordinary characters are directly copied, tab, newline and backslash are escaped using \t, \n and \\,  a
       percent sign is represented by %%, and otherwise % indicates a conversion.  The program time will always add a trailing newline itself.  The conversions follow.
       All of those used by tcsh(1) are supported.

       Time

       %E     Elapsed real time (in [hours:]minutes:seconds).

所以我不想让那些令人困惑的厘秒。该格式应该是逻辑的,易于阅读,而不使用sed之类的其他脚本。当我有几个命令的日志时,输出应该是这样的:

time=0:00:01
time=3:30:12
time=0:10:01

0 个答案:

没有答案