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

AbotX : How do you create a parallel crawler that stays on and can be added to at run time from new requests -

testing - Detect whether test has failed within fixture -

android - Create single AAR file from multiple modules using Gradle -