I am trying to dynamically add an element to an array:
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
But it returns element1 .
I tried with the index but get the same result:
fa[index]="$i" ((index++))
Am I doing something wrong here?
bash shell
paul
source share