title: How can I do bash arithmetic with variables that are numbers with leading zeroes?
body: <p>I have the following code in a bash script, where "values" is a variable of newline separated numbers, <strong>some of which have leading 0's</strong>, and I am trying to iterate through each value in values and add each value to the variable "sum".</p>
  
  <pre><code>sum=0
  while read line; do
      sum=$(( sum + line ))
  done &lt;&lt;&lt; "$values"
  </code></pre>
  
  <p>this code segment gives me the error: "value too great for base (error token is "09")", which as I understand, is because the bash arithmetic expression interprets the value "line" to be an octal value because it has a leading zero.</p>
  
  <p>How can I allow for bash to interpret the value of line to be its decimal value? (e.g. 09 -> 9) for the value "line" within this bash arithmetic expression? </p>