Question: what does this line do? Can someone please explain?
if [ $((${array[$i]}+1)) -ne ${array[$(($i + 1))]} ] ;then foo; fi
[ ... -ne ... ] - test for inequality
$(( ... + 1)) - add one, arithmetic expansion
${array[$i]} - reference to element $i of an array variable
Or in other words the test is A[i] + 1 != A[i + 1]
if ((array[i] + 1 != array[i+1])); then foo; fi(as long as$iandarray[i+1]contain decimal integers).[$i]in$array, adds one to it - inside an arithmetic context, then returns (via command substitution) that as the LHS operand to the-neconditional operator, then evaluates the RHS operand,$(($i + 1))is variable$i + 1then the result of this arithmetic operation is used as the key/position in the array${array[]}- if the LHS and the RHS results are-ne"not equal` thethenblock runsif [[ array[i]+1 -ne array[i+1] ]] ;then foo; fias both sides of an integer operator are processed as arithmetic expansions. In math: test forA[i]+1 = A[i+1]. Or, in words: is the next array element the consecutive numeric value of the present one?