12
我想用gnu時間來測量一些小的.c程序的運行時間。在該男子就被寫:Gnu時間和格式化輸出
-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
我想知道問題在哪裏,我在哪裏犯錯?我只是想顯示用戶時間,這就是爲什麼我用時間輸出格式玩弄。
感謝您的快速回答,我將只使用TIMEFORMAT,但所有這些工作。 – Andna 2012-03-15 07:53:02
某些系統(例如NixOS)不提供'/ usr/bin/time',但我發現'command time ...'可以避免bash內建。 – Warbo 2017-04-21 22:32:27
好的一點,'command'是一個POSIX定義的shell實用程序,所以它應該在'sh'和任何可以充當'sh'的任何東西(包括'bash'和'ksh')中可用。正如在此提到的:https://stackoverflow.com/questions/6365795/invoking-program-when-a-bash-function-has-the-same-name – minopret 2017-04-25 23:17:07