LoginSignup
3
2

More than 5 years have passed since last update.

角括弧2個([[ 条件式 ]])の条件式でAND条件「-a」が使えない件(回避方法あり)

Posted at
$ [[ 11 -eq 11 -a "bb" = "bb" ]]; echo $?
-bash: syntax error in conditional expression
-bash: syntax error near `-a'

怒られた。

$ [[ 11 -eq 11 && "bb" = "bb" ]]; echo $?
0

&&だといいみたい。

orも

$ [[ 11 -eq 11 -o "bb" = "ab" ]]; echo $?
-bash: syntax error in conditional expression
-bash: syntax error near `-o'

$ [[ 11 -eq 11 || "bb" = "ab" ]]; echo $?
0
3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2