How to add the new element to an array (without index) in Bash
To add the new element to an array without specifying its index, we can use the variable followed by the +=
operator in bash.
Here is an example, that adds the two elements (‘apples’, ‘grapes’) to the following array.
arr=()
arr+=('apples')
arr+=('grapes')
echo ${arr[@]}
Output:
apple grapes