Gnu时间和格式输出

And*_*dna 13 linux gnu

我想用gnu时间测量一些小.c程序的运行时间.在这个人写的是:

-f FORMAT, --format FORMAT
Use FORMAT as the format string that controls the output of time.  See the below more information.
Run Code Online (Sandbox Code Playgroud)

然后在示例中我们有:

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
Run Code Online (Sandbox Code Playgroud)

但是当我尝试从示例中发出此命令时,我得到:

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

real    0m0.134s
user    0m0.084s
sys     0m0.044s
Run Code Online (Sandbox Code Playgroud)

我想知道问题出在哪里,我在哪里弄错了?我只是想显示用户时间,这就是为什么我玩弄时间输出格式.

min*_*ret 13

Bash for one有一个内置的shell命名time.克服它的一种方法是输入command time.另一种方式是time.另一方面,bash builtin尊重环境变量$PATH.

  • `/usr/bin/time` 在某些系统(例如 NixOS)上不可用,但我发现 `command time ...` 可以作为避免内置 bash 的方法。 (2认同)