bash add item to array code example
Example 1: how to append an array in bash
#!/bin/bash
#Making an array
array=(1 2 3)
#Appending the array
array+=(4)
#Printing the array
echo ${array[@}
# output: 1 2 3 4
Example 2: bash adding to array
#!/bin/bash
#Making an array
array=(1 2 3)
#Appending the array
array+=(4)
#Printing the array
echo ${array[@]}