bash initialize array 1

bash initialize array

#to create an array:
$ declare -a my_array
#set number of items with spaceBar seperation:
$ my_array = (item1 item2)
#set specific index item:
$ my_array[0] = item1

Here is what the above code is Doing:
1. Declare an array named my_array.
2. Set the first element in the array to be “item1”.
3. Set the second element in the array to be “item2”.

Similar Posts