我正在尝试动态地将一个元素添加到数组中:
array=("element1" "element2" "element3")
fa=()
# now loop through the above array
for i in "${array[@]}"
do
fa+=("$i")
# or do whatever with individual element of the array
done
echo $fa
但它返回的是 element1
。
我尝试使用索引,但结果相同:
fa[index]="$i"
((index++))
这里我做错了什么吗?
fa+=("$i")
这种风格。 - sjsam