【发布时间】:2018-09-04 23:20:44
【问题描述】:
我遇到了这个烦人的问题,连我的老师都解决不了:/. 我想用从 1 到 100 的总和值填充一个数组,这是我的代码:
while [ $i -le 100 ]
do
#filling the list with the sums of i at the pos i
sumList[$i]=$(echo $i | sum)
echo $i |sum
echo $sumList[$i]
i=$(($i+1))
done
由于某种原因,它只是用第一个值 (00034 1) 填充所有点 我不知道该怎么办
【问题讨论】:
-
和00034 1是0的和值
-
什么是
sum?而echo $sumList[$i]应该是echo ${sumList[$i]}。
标签: arrays linux bash for-loop sum