Having the following:
#!/usr/bin/env dash
seq -w 10 | while read -r num
do
echo $num: $((num + 1))
done
prints
01: 2
02: 3
03: 4
04: 5
05: 6
06: 7
07: 8
sd: 3: sd: Illegal number: 08
Can anyone explain what is the problem with above dash
artihmetic?
note, it is an dash (not bash) script.
Tagged it as bash
too, for more attention from bash-experts too. :)
Problem is leading 0
in your seq
output that makes it an octal number and anything above 07
is an invalid octal number.
Note that this script will work fine without error:
seq 10 | while read -r num; do echo "$num: $((num + 1))"; done