Addition in bash
Andrew Farris
flyindragon1 at aol.com
Wed Oct 14 08:02:14 UTC 2009
On Wed, 2009-10-14 at 00:24 -0700, Ray Parrish wrote:
> Hello,
>
> I have the following script fragment
>
> Seconds=0;
> while [ "$Seconds" -lt "60" ]
> do
> sleep 5;
> Seconds=$Seconds+5;
> padsp espeak "$Seconds"
> done
>
> For some reason Seconds becomes "0+5" instead of the integer value 5
> which is what I am attempting to get it to be.
>
> Does anyone know how to do integer math in bash?
I believe it should look like this:
---------------------------------------
#!/bin/bash
Seconds=0;
while [ "$Seconds" -lt "60" ]
do
sleep 5;
Seconds=$((Seconds+5));
padsp espeak "$Seconds"
done
---------------------------------------
This works for me, though it gives no output unless I replace 'padsp
espeak' with 'echo'.
Hope that helps!
--
Andrew
_____________________________
Registered Linux User: 473690
Registered Ubuntu User: 22747
More information about the ubuntu-users
mailing list