Gnu time and formatting output

你离开我真会死。 提交于 2019-12-04 17:03:52

问题


I wanted to use gnu time to measure running time of some little .c programs. In the man it is written that:

-f FORMAT, --format FORMAT
Use FORMAT as the format string that controls the output of time.  See the below more information.

Then in examples we have:

To run the command `ls -Fs' and show just the user, system, and total time:
time -f "%E real,%U user,%S sys" ls -Fs

But when I try to issue this command from example i get:

time -f '%E real,%U user,%S sys' ls -Fs
-f: command not found

real    0m0.134s
user    0m0.084s
sys     0m0.044s

I am wondering where is the problem, where am I making a mistake? I just want to show the user time, that is why I am toying with time output format.


回答1:


Bash for one has a shell builtin named time. One way to get past it is to type command time - command will ignore the builtins and run the time program from your $PATH. Another way is alias time=/usr/bin/time. On the other hand the bash builtin respects environment variable TIMEFORMAT.



来源:https://stackoverflow.com/questions/9715570/gnu-time-and-formatting-output

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!