Loop which will fail with this error nodes="0" nodestotal="20" while [ ${nodes} -lt ${nodestotal} ] do if [ "${nodes}" -lt "10" ] then nodes="0${nodes}" fi echo ${nodes} nodes=$[${nodes}+1] done Solution nodes="0" nodestotal="20" while [ ${nodes} -lt ${nodestotal} ] do if [ "${nodes}" -lt "10" ] then nodes="0${nodes}" fi echo ${nodes} nodes=$[$((10#${nodes}))+1] done 10#${nodes} = base#number (in this case we want to be using base 10)