Mat*_*ers 32 bash shell scripting
我想创建一个脚本,只输出time命令的实时值,这样我就可以绘制结果.例如time command输出
real    1m0.001s
user    1m0.000s
sys  0m0.001s
Run Code Online (Sandbox Code Playgroud)
我想写一个输出的脚本
60.001 
Run Code Online (Sandbox Code Playgroud)
如何在几秒钟内从'time'命令获得实时值?
Pau*_*ce. 44
如果您正在使用Bash内置time,请将TIMEFORMAT变量设置为%R:
$ TIMEFORMAT=%R
$ time sleep 1
1.022
Run Code Online (Sandbox Code Playgroud)
        eum*_*iro 22
According to time, the following should work:
/usr/bin/time -f "%e" sleep 3
3.00
Run Code Online (Sandbox Code Playgroud)
EDIT: call the --format command with its path:
/usr/bin/time -f "%e" sleep 3
3.00
Run Code Online (Sandbox Code Playgroud)
Without the path, it was using some -f's equivalent. With the path, it works for me.