Bash programming only supports one-dimensional arrays, does not support multidimensional, like C, array subscript starting from 0, subscript can be an integer, or it can be an expression
Definition of an array
Use parentheses in the shell to represent the array, separated by a space in the middle
There are two main forms of definition:
Arr= (1 2 3 4 5 6)
Arr= (
1
2
3
4
)
You can also define the components of an array separately
Arr[0]=1
arr[1]=2
Arr[2]=3
Arr[3]=4
You can not use successive subscripts, and there is no limit to the range of subscript
Reading an array
The general format of reading data is ${arr[index]}
echo ${arr[1]} >>2
Use @ or * to get all the elements in the array
${arr[*]} >>1 2 3 4
Gets the length of the array
Gets the length of the array and gets the string length in the same way as echo ${#arr [*]} echo ${#arr [@]}
Gets the length of an array of individual elements echo ${#arr [n]}
Array of Shell programming