Chinaunix
标题:
test 与 [[ ]] , 这个[[ ]] 该怎么理解?
[打印本页]
作者:
micra
时间:
2007-12-03 09:22
标题:
test 与 [[ ]] , 这个[[ ]] 该怎么理解?
比如以前用:
if [ "$answer" = yes ]
这里的 "[" 是等同于test 命令的,不过多了个表示结束的 "]"
现在可以用:
if [[ $answer = yes ]]
那么这里的两个 "[" 该怎么理解?
作者:
waker
时间:
2007-12-03 09:28
[[ expression ]]
Return a status of 0 or 1 depending on the evaluation of the
conditional expression expression. Expressions are composed of
the primaries described below under CONDITIONAL EXPRESSIONS.
Word splitting and pathname expansion are not performed on the
words between the [[ and ]]; tilde expansion, parameter and
variable expansion, arithmetic expansion, command substitution,
process substitution, and quote removal are performed. Condi-
tional operators such as -f must be unquoted to be recognized
as primaries.
复制代码
作者:
davistar
时间:
2007-12-03 09:29
http://bbs.chinaunix.net/viewthread.php?tid=278896&extra=page%3D1%26amp%3Bfilter%3Ddigest
作者:
micra
时间:
2007-12-03 11:28
标题:
回复 2楼 3楼
谢谢楼上两位,还是我不够仔细。
原来 [[ 是关键字。
另外想问一下:在调用的时候,关键字和内置命令之间有什么区别?(或者关键字也是内置命令的一种?)
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2