So, I'm trying to calculate 12-08 (not 12-8) and get the following error:
let: 08: value too great for base (error token is "08")Here's the sample code:
first=12
second=08
if [[ ($first > $second) ]]; then let fin=first-second
else let fin=second-first
fiP.S Sorry about the spacings
11 Answer
If you precede a number by 0, bash treats the number as octal. As octal is base 8 with digits ranging from 0 to 7, 08 is out of range for octal.
Now you have two options to do decimal calculation:
Omit preceding 0:
$ echo $(( 12 - 8 )) 4Explicitly mention base as decimal by
10#:$ echo $(( 12 - 10#08 )) 4