Gnu时间和格式输出 [英] Gnu time and formatting output

查看:109
本文介绍了Gnu时间和格式输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用gnu time来测量一些小.c程序的运行时间.在该人中写道:

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.

然后在示例中有:

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.

推荐答案

一个Bash具有一个内置的名为time的shell.克服它的一种方法是键入command time-命令将忽略内置文件,并从$PATH运行time程序.另一种方法是alias time=/usr/bin/time.另一方面,内置的bash尊重环境变量TIMEFORMAT.

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.

这篇关于Gnu时间和格式输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆