1.[
"["是一个可执行程序,路径是"/usr/bin/["
他与可执行程序"test"是等价的。

例子:

if [ 3 -eq 2 ] ; then
 echo "==";
else
 echo "!=";
fi;

等价于:

if /usr/bin/[ 3 -eq 2 ] ; then
 echo "==";
else
 echo "!=";
fi;

等价于:

if test 3 -eq 2  ; then
 echo "==";
else
 echo "!=";
fi;

2.[[
"[["是脚本解释程序(bash,sh等)的关键字
例子:

if [[ 2 == 2 ]] ; then
 echo "==";
else
 echo "!=";
fi;

推荐使用“[[”。


本文链接地址: 体验Linux.6 shell中[与[[的区别(中括号与双层中括号的区别)
https://blog.qingfengju.com/index.asp?id=280

上一篇: msys+mingw的基本配置
下一篇: 用Grub中引导Windows

分类:Linux 查看次数:8529 发布时间:2011/12/4 12:45:13