Bash tips: Append elements to array without specifying the index

Written on 26 June 2017

Append elements to array, add a new element to an array without specifying the index.
Declare bash array

array=(a b c d)  

Append new element to this bash array:

array=("${array[@]" "e"}  

If you use


First, it check the current number of array element, then add new element to end of array.

Read more on bash Bash Tips