linux: time vs /usr/bin/time 为什么time命令使用参数没有作用?

time

time是bash的shell keyword,而不是 shell buildin
在这里插入图片描述
可以使用命令help time查看这个time 关键字的使用方法

time: time [-p] pipeline
    Report time consumed by pipeline's execution.
    
    Execute PIPELINE and print a summary of the real time, user CPU time,
    and system CPU time spent executing PIPELINE when it terminates.
    
    Options:
      -p	print the timing summary in the portable Posix format
    
    The value of the TIMEFORMAT variable is used as the output format.
    
    Exit Status:
    The return status is the return status of PIPELINE.

简单来说就是:可以检测一个管道的执行时间。
在这里插入图片描述

/usr/bin/time

/usr/bin/time是一个二进制可执行文件,是“真正”的time 命令,用来运行并且显示一个程序的资源使用情况。
其实在time 命令的使用手册中(man time)也告诉我们,bash 的使用者需要显式调用该命令。

  Users of the bash shell need to use an explicit path in order to run
  the external time command and not the shell builtin variant.  On system
  where time is installed in /usr/bin, the first example would become
       /usr/bin/time wc /etc/hosts

调用/usr/bin/time 的几种方法

  • 显式调用
    /usr/bin/time wc /etc/hosts
    
  • 使用\让shell忽略别名(alias)和关键字(keywords)
    \time wc /etc/hosts
    
  • 使用command
    command time wc /etc/hosts
    

参考

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值