title: Error running if statements in bash script
body: <p>Here I have a basic bash script written. I want the if blocks to organize where to write output to. Is there a syntax error with the way I have written my conditional logic? The error I am getting is for every line where I have an if or elif statement. I believe it may have something to do with the -eq comparison operator or possibly a lack or parentheses.</p>
  
  <p>Here is an example of the error I am having (the last errors that occur in the terminal; closest to the bottom):</p>
  
  <p>./lit: line 17: [2: command not found</p>
  
  <p>./lit: line 20: [2: command not found</p>
  
  <p>./lit: line 23: [2: command not found</p>
  
  <p>./lit: line 28: [3: command not found</p>
  
  <p>./lit: line 31: [3: command not found</p>
  
  <p>./lit: line 34: [3: command not found</p>
  
  <p>./lit: line 37: [3: command not found</p>
  
  <p>./lit: line 42: [3: command not found</p>
  
  <p>./lit: line 45: [3: command not found</p>
  
  <p>./lit: line 48: [3: command not found</p>
  
  <p>./lit: line 51: [3: command not found</p>
  
  <p>./lit: line 56: [3: command not found</p>
  
  <p>./lit: line 59: [3: command not found</p>
  
  <p>./lit: line 62: [3: command not found</p>
  
  <p>./lit: line 65: [3: command not found</p>
  
  <pre><code>for i in {0..2};
  do
      for j in {0..3};
      do
          for k in {0..3}
          do
              for l in {0..3}
              do
  
                  START=$(date +%s.%N)
                    #some command here
                  END=$(date +%s.%N)
                  DIFF=$(echo "$END - $START" | bc)
  
                  if ["$i" -eq "0"];
                  then
                      echo "test$i$j$k$l $DIFF" &gt;&gt; repeatSample.txt;
                  elif ["$i" -eq "1"]
                  then 
                      echo "test$i$j$k$l $DIFF" &gt;&gt; writeZeroes.txt
                  elif ["$i" -eq "2"]
                  then
                      echo "test$i$j$k$l $DIFF" &gt;&gt; repeatPacket.txt
                  fi
  
                  if [$j -eq 0]
                  then
                      echo "test$i$j$k$l $DIFF" &gt;&gt; byte15.txt
                  elif [$j -eq 1]
                  then
                      echo "test$i$j$k$l $DIFF" &gt;&gt; byte100.txt
                  elif [$j -eq 2]
                  then
                      echo "test$i$j$k$l $DIFF" &gt;&gt; byte500.txt
                  elif [$j -eq 3]
                  then
                      echo "test$i$j$k$l $DIFF" &gt;&gt; byte1000.txt
                  fi
  
                  if [$k -eq 0]
                  then
                      echo "test$i$j$k$l $DIFF" &gt;&gt; loss10.txt
                  elif [$k -eq 1]
                  then
                      echo "test$i$j$k$l $DIFF" &gt;&gt; loss22.txt
                  elif [$k -eq 2]
                  then
                      echo "test$i$j$k$l $DIFF" &gt;&gt; loss37.txt
                  elif [$k -eq 3]
                  then
                      echo "test$i$j$k$l $DIFF" &gt;&gt; loss50.txt
                  fi
  
                  if [$l -eq 0]
                  then
                      echo "test$i$j$k$l $DIFF" &gt;&gt; pinkpanth.txt
                  elif [$l -eq 1]
                  then
                      echo "test$i$j$k$l $DIFF" &gt;&gt; poeee.txt
                  elif [$l -eq 2]
                  then
                      echo "test$i$j$k$l $DIFF" &gt;&gt; dooors.txt
                  elif [$l -eq 3]
                  then
                      echo "test$i$j$k$l $DIFF" &gt;&gt; simplehead.txt
                  fi
  
              done
          done
      done
  done
  </code></pre>