Inside a loop I have a variable to be used for the calculation, using bc
, of another variable.
However, the result I get is totally incorrect. I have 32 files, named test0
, test1
and so on.
My script reads as follow:
for i in {0..31}; do
declare x$i=$(wc -l < test$i)
declare y$i=$(echo $x$i/10 | bc)
done
for the variable x
, I get the good results, i.e. each x$i
stores the number of lines of the correspondent test$i
. Then I'd like to simple know how much is 10% of each x$i
and stores it in variables y$i
. And, as I said above, I get completely wrong results using that script.
For example, for x0
=155287510 I got y0
=20.