bash - Add element into Array -
i´m trying dynamically add element array:
array=("element1" "element2" "element3") fa=() # loop through above array in "${array[@]}" fa+=("$i") # or whatever individual element of array done echo $fa
but it's returning element1
.
i've tried index, i'm getting same result:
fa[index]="$i" ((index++))
am doing wrong here?
the problem printing ie echo $fa
. equivalent echo ${fa[0]}
means first element of array, gotelement1
echo "${fa[@]}"
should give entire array.
reference
[ ] should give nice description bash arrays.
Comments
Post a Comment