[]with[[]]
2076 ワード
[brand@localhost ~]$ echo $name hello
hello
[brand@localhost ~]$ [$name = "hello"]
-bash: [: missing `]' #[ ]
[brand@localhost ~]$ [ $name = "hello" ]
-bash: [: =: unary operator expected# $,
[brand@localhost ~]$ [[ $name = "hello" ]]
[brand@localhost ~]$ echo $?
0
[brand@localhost ~]$ [[ "$name" = "hello" ]]
[brand@localhost ~]$ echo $?
0
[brand@localhost ~]$ [ "$name" = "hello" ]
[brand@localhost ~]$ echo $?
0
[brand@localhost ~]$
[]はshellに埋め込まれたコマンドで、実行されます.
[]]はusr/bin/test
()数値計算用