This is the night of my own leisure. Learning Solr suddenly saw the definition of the array, want to forward a more detailed array operation.
1. Array definitions
A= (1 2 3 4 5)
Echo $a
A pair of parentheses indicates an array, and the elements of the array are separated by a "space" symbol.
2. Array reading and Assignment
echo ${#a [@]}
5
Use ${#数组名 [@ or *]} to get the array length
Echo ${a[2]}
3
Echo ${a[*]}
1 2 3) 4 5
Using the ${array name [subscript]} subscript is starting from 0 subscript is: * or @ Get the entire array contents
a[1]=100
Echo ${a[*]}
1 100 3) 4 5
a[5]=100
Echo ${a[*]}
1 100 3 4 5 100
It can be referenced directly by the array name [subscript], and if the subscript does not exist, a new array element is added automatically
A= (1 2 3 4 5)
Unset A
Echo ${a[*]}
A= (1 2 3 4 5)
Unset A[1]
Echo ${a[*]}
1 3 4 5
echo ${#a [*]}
4
Directly through: unset array [subscript] can clear the corresponding element, without subscript, clear the entire data.
3. Special use
A= (1 2 3 4 5)
Echo ${a[@]:0:3}
1 2 3
Echo ${a[@]:1:4}
2 3 4 5
C= (${a[@]:1:4})
echo ${#c [@]}
4
Echo ${c[*]}
2 3 4 5
Directly through the ${array name [@ or *]: Start position: Length} Slice the original array, return is a string, the middle with "space" separate, so if you add "()", will get the slice array, the above example: C is a new data.
a= (1 2 3 4 5)
echo ${a[@]/3/100}
1 2 4 5
1 2 3 4 5
a= (${a[@]/3/100})
echo ${a[@]}  
1 2 4 5
The call method is: ${array name [@ or *]/find character/substitution character} This operation will not change the original array contents, if you need to modify, you can see the above example, redefine the data.
As you can see from the above, the array of Linux shells is already powerful, and the usual operations are more than enough
Shell array Definitions and operations