title: Syntax error: operand expected when using Bash
body: <p>I have two arrays that I want to loop in. I construct those properly and before going into for loop, I do echo them to be sure everything is ok with arrays.
  But when I run the script, it outputs an error:</p>
  
  <pre><code>l&lt;=: syntax error: operand expected (error token is "&lt;="
  </code></pre>
  
  <p>I consulted the mighty Google and I understood it suffers from the lack of the second variable, but I mentioned earlier I do echo the values and everything seems to be OK. Here is the snippet..</p>
  
  <pre><code>#!/bin/bash
      k=0
      #this loop is just for being sure array is loaded
      while [[ $k -le ${#hitEnd[@]} ]] 
        do
        echo "hitEnd is: ${hitEnd[k]} and hitStart is: ${hitStart[k]}"
        # here outputs the values correct 
        k=$((k+1))
      done
      k=0
      for ((l=${hitStart[k]};l&lt;=${hitEnd[k]};l++)) ; do //this is error line..
          let array[l]++      
          k=$((k+1))
  done
  </code></pre>
  
  <p>The variables in the for loop are echoed correctly but for loop won't work.. where am I wrong?</p>
  
  #
  
  <p>as gniourf_gniourf answered:</p>
  
  <blockquote>
    <p>"... At some point, k will reach the value ${#hitEnd[@]}, and this is
    exactly when hitEnd[k] is not defined and expands to an empty string!
    Bang!"</p>
  </blockquote>
  
  <p>meaning error output is displayed not at the beginning of the loop, but when k has a greater value than array's indices, pointing an index that array does not include...</p>