为什么命令选项"-f"被bash视为命令

Yan*_*Xie 3 bash shell

我运行从时间的手册复制的命令,但它没有找到-f命令.为什么它将-f识别为命令?

$ time -f "%E real,%U user,%s sys" ls -Fs
-f: command not found

real    0m0.152s
user    0m0.108s
sys 0m0.040s
Run Code Online (Sandbox Code Playgroud)

我怀疑shell并决定尝试另一个shell.在上面,shell是bash.我切换到破折号,现在发现时间正确.

我的系统是Linux Mint 13.

Hri*_*iev 6

time是一个内置的命令bashzsh.如果您想要执行外部命令,则应该调用/usr/bin/time -f ....


che*_*ner 5

您可以使用bash内置command来抑制shell函数和内置函数:

command time -f "%E real,%U user,%s sys" ls -Fs
Run Code Online (Sandbox Code Playgroud)

(比使用更长,但更明确一点\time.)