Tekkaman

导航

 

[bash's [ command & [[ keyword]

[ (test) command:

  bash中的条件测试語句, [ condition ], 并不是一个語句, 而是一个命令, 命令的名字是 [ , 这个命令期待最后一个参数是 ] .

  在terminal中键入 whereis [, 可以看到[ 命令被放在系统中的哪个地方.

  

[[ keyword:

  [[是[的扩展, 是bash中的keyword,提供比[更强大的功能, 更方便的使用方法.

  

  Special primitives that [[ is defined to have, but [ may be lacking (depending on the implementation):

  

  As a rule of thumb, [[ is used for strings and files. If you want to compare numbers, use an ArithmeticExpression

参考:

  1. http://bash.cumulonim.biz/FullBashGuide.html

  2. http://bash.cumulonim.biz/BashFAQ(2f)031.html

posted on 2013-12-04 10:02  Tekkaman  阅读(252)  评论(0编辑  收藏  举报