Calculate the sum of 200 variables VAR_01 the VAR_200 in bash script
$10-40 USD
Concluído
Publicado há aproximadamente 9 anos
$10-40 USD
Pago na entrega
I have 100 variables, created in VAR_01 to VAR_100 by another script.
Necessary to add the final value of them. That's it .....
I've tried
--------------------------------------------------------------------------
!/bin/bash
for i in $(seq 1 100)
do
COUTER=`echo "$COUTER + $VAR_$i" | bc`
done
--------------------------------------------------------------------------
but not works !!!!
These variables were 100 are created by another scrit, which runs before that party must do the sum.
I would like to find the best way to do this safely and efficiently.
Please explain it a little better what is var_01 to var_100 are they files?
Do you want to count all variables and in an output file and write the final value at the end of the file?
Regards
usman