LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
123
返回列表 发新帖
楼主: yongjian

time date 的output [己解决]

[复制链接]
 楼主| 发表于 2005-8-17 09:45:04 | 显示全部楼层
Post by hellwolf
但道理却不是我说的那个道理(输出到/dev/tty)

直是因为重定向符号是针对后面的命令而已,不会针对time

格式是:
time [command]

很容易证明:
$time | less
-bash: syntax error near unexpected token `|'

怎么样,time不是个普通的东西,bash对自己的内建函数是不做重定向的。

我上面的推断完全是从现象推原因的,所以出错了

不对吧。set, ulimit, pwd等等大批bash的builtin都是可以做重定向的。time这个命令是很特殊。
回复 支持 反对

使用道具 举报

发表于 2005-8-17 11:11:59 | 显示全部楼层
$type time
time is a shell keyword

time不是bash的builtin。呵呵,是特殊了点。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-8-17 22:46:40 | 显示全部楼层
Post by hellwolf
$type time
time is a shell keyword

time不是bash的builtin。呵呵,是特殊了点。

看来我有必要再会去多看看书了。这是我从abs上quote下来的对于keyword, builtin, time等的一些解释。让我们彻底的把这个特殊的命令看清楚吧。

"A keyword  is a reserved word, token or operator. Keywords have a special meaning to the shell, and indeed are the building blocks of the shell's syntax. As examples, "for", "while", "do", and "!" are keywords. Similar to a builtin, a keyword is hard-coded into Bash, but unlike a builtin, a keyword is not by itself a command, but part of a larger command structure.”

"An exception to this is the time command, listed in the official Bash documentation as a keyword."

"As of version 2.0  of Bash, time became a shell reserved word, with slightly altered behavior in a pipeline."
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表