Getting the following error in your script '-bash: 08: value too great for base (error token is "08")'

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)

Share