bash adding to array 1

bash adding to array

#!/bin/bash

#Making an array
array=(1 2 3)

#Appending the array
array+=(4)

#Printing the array
echo ${array[@]}

Here is what the above code is Doing:
1. We are creating an array with three elements.
2. We are appending the array with another element.
3. We are printing the array.

Similar Posts