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

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -