cs1=`echo "scale=8;($css1/$css0)*100"|bc`
cs2=`echo "scale=8;($css2/$css0)*100"|bc`
cs3=`echo "scale=8;($css3/$css0)*100"|bc`
cs4=`echo "scale=8;($css4/$css0)*100"|bc`
cs5=`echo "scale=8;($css5/$css0)*100"|bc`
cs6=`echo "scale=8;($css6/$css0)*100"|bc`
cs7=`echo "scale=8;($css7/$css0)*100"|bc`
cs8=`echo "scale=8;($css8/$css0)*100"|bc`
cs9=`echo "scale=8;($css9/$css0)*100"|bc`
Instead of using the above code, if I use the below to reduce the script size, it is not working. Please help
for i in 1 2 3 4 5 6 7 8 9
do
eval cs$i=`echo "scale=8;($css'$i'/$css0)*100"|bc`
done
ctsgnb
3
in your for loop try to replace with the line (there are 6 simple quote,2 back quote and 2 double quote... don't forget some...)
eval 'cs'$i'=`echo "scale=8;($css'$i'/$css0)*100"|bc`'
Otherwise
for i in 1 2 3 4 5 6 7 8 9
do
t=$(eval echo "\(\$css$i/\$css0\)*100")
eval cs$i=`echo "scale=8;$t"|bc`
done
pludi
4
Since you can't eval
in eval
:
for i in {1..8}
do
tmp="cs$i=\$(echo \"scale=8;(\$css$i/$css0)*100\"|bc)"
eval $tmp
tmp2="echo cs$i is \$cs$i"
eval $tmp2
done
ctsgnb
5
I tested & fixed my previous post, use simple quoting for the one line eval :
Give a try to the following :
for i in 1 2 3 4 5 6 7 8 9
do
eval 'cs'$i'=`echo "scale=8;($css'$i'/$css0)*100"|bc`'
done
(don't forget any of the 6 simple quote)