linux - Gnu 时间和格式化输出

标签 linux gnu

我想使用 gnu time 来测量一些小的 .c 程序的运行时间。在男人身上写着:

-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

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

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

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

我想知道问题出在哪里,我哪里出错了?我只想显示用户时间,这就是我玩弄时间输出格式的原因。

最佳答案

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

关于linux - Gnu 时间和格式化输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9715570/

相关文章:

ubuntu - 在 ubuntu 中替代 niceload 命令?

windows - Windows 中的 MSYS 主文件夹

perl - 对 Perl 模块表示赞赏

linux - aix/ksh shell 前后的 grep 行

linux - 在linux中安装英语词典

linux - 使用 Nagios 监控 CPU 负载、系统性能和 Zombie

c++ - 比较 timespec 值

linux - 为什么 GNU sort 会在这个特定文件上挂起 10 个小时以上

linux - 在后台运行进程会降低其权限吗?

linux - yad - 使用变量