[ILUG-BOM] bc and bash scripting woes
Dinesh Shah
dinesh@[EMAIL-PROTECTED]
Wed Jan 16 15:33:02 IST 2002
Hi,
try
SUM=0; for i in `seq 0 10`; do SUM=`echo "$SUM+$i"|bc`; echo -n $SUM ;done
here is the o/p...
0 1 3 6 10 15 21 28 36 45
55
On Tue, 15 Jan 2002, Parvez Lanewala wrote:
> hi luggers,
>
>
> i'm having a problem with the following code...
>
> --snip--
>
> for i in `seq 0 10`;
> do
> SUM=`echo $SUM+${ARR[$i]}|bc`
> done
>
> --snip--
>
> error says : (standard_in) 1: parse error
>
> although the segment
>
> echo $SUM+${ARR[$i]}|bc
>
> works fine outside the for loop. any hints on why and how i can avoid it.
>
> thanks,
> parvez
>
>
>
--
--Dinesh Shah :-)
Shah Micro System
dinesh at indiamail.com
http://dineshah.tripod.com
Mobile: 98213-11906
More information about the Linuxers
mailing list