Bash supports one-dimensional arrays and does not qualify the size of the array, and the subscript of the array element is numbered starting with 0.
Defining arrays
In the shell, the array is represented by parentheses, and the elements of the array are separated by a "space" symbol. The general form of the definition array is:
Array_name= (value0 value1 value2 value3)
Each array element can also be defined individually
array_name[0]=value0array_name[1]=value1array_name[2]=value2
Reading an array
The general format for reading array element values is:
${array_name[index]}
Use @ or * to get all the elements in the array:
${array_name[*]}${array_name[@]}
Gets the length of the array
The method of getting the length of the array is the same as getting the string length
# Gets the number of array elements length =${#array_name [*]}# gets the lengths of the individual elements of the array lengthn=${#array_name [n]}
Shell script: Array