On Ubuntu 14.04.1 64-bit LTS I am writing a shell script and if I define the start of the
sequence used in the
for loop with a variable instead of a constant I get really weird behavior and there are lots of errors from the
bc calculator. You can run the following code snippet to reproduce the errors:
#!/bin/bash S=0.030 F=0.150 N=30 DIFF=`echo $F - $S | bc -l` dw=`echo $DIFF / $N | bc -l` is=`echo $S / $dw | bc -l` if=`echo $F / $dw | bc -l` for i in `seq $is $if` do w=`echo "scale=3; $i * $dw" | bc -l` done
If I change the start of the sequence to a constant it works perfectly, but when it is a variable there are problems the output is as follows:
(standard_in) 1: syntax error ... ... (standard_in) 1: syntax error
What may be the reason behind this behaviour? I would like to receive your suggestions and comments.