| arithmatic in shell script I am writing a script that outputs the fibanocci sequence and gives as many terms as specified by the argument.
#!/bin/sh
clear
i=0
a=0
b=0
echo "this is i $1"
while [ `expr $i` -lt `expr $1` ]
do
c=`expr $a+$b`
echo " $c"
a=$b
b=$c
i=`expr $i+1`
done
The error I get is this is i 6
0+0
./Fibanocci.sh: line 7: [: 0+1: integer expression expected
I'm guessing the problem is that arguments are automatically a string type so that's why I have the `expr`s inside the while loop. |