Looping and Skipping

  • + 1 comment

    Three things :


    1) i = $((i+2)) will give an error because of extra space around "=". It can be corrected to : i=$((i+2))


    2) The above mentioned line i=$((i+2)) is actually unnecessary because the updated value of i is never used, and overwritten by for in next iteration. Hence, this line can be completely removed.


    3) Use for i in {1..100..2} instead of for i in {1..100} to get increment of 2.