Code:
#!/bin/bash
until [ $i -eq 10 ]
do
$i = /dev/random
$sum = $sum + $i
done
echo "The total is: $sum"
This is slightly wrong; you must remove the
$ at left hand sides, and beware the spaces in bash scripts, they have to be used when they have to, no more no less.
Moreover, you should initialize the variables, for safety.
This should work:
Code:
#!/bin/bash
sum=0
for j in 0 1 2 3 4 5 6 7 8 9
do
i=$RANDOM
sum=$[sum+i]
done
echo "The total is: $sum"
If you want to read in the numbers from command line (interactively) use the read command ("man read" for more help):
instead of
use
Regards