Article Directory
- Array
- Pass array parameters to the function
- Return an array from a function
Array
How to define an array
(30 20 10 60 50 40)
对应的索引号 0 1 2 3 4 5
method one
Array name=(value0 value1 value 2 …)
Method Two
Array name=([0]=value [1]=value [2]=value...)
Method Three
List name = "value0 value1 value2..."
Array name = ($list name)
Method Four
Array name [0] = "value"
Array name [1] = "value"
Array name [2] = "value"
How to get the data list
echo ${
arr_number[*]}
echo ${
arr_number[@]}
Get an element with a fixed index
Get the length of the array
Data types included in the array
使用" "或' '定义
Numerical type
Character type
Array traversal-the different meanings of * and @
Array slice
Array replacement
Array delete
Array append element
method one
Method Two
Method Three
Method Four
Pass array parameters to the function
If you directly use the array as a function parameter, the
solution to the problem is to first decompose the value of the array variable into a single value, and then use it as a function parameter
Return an array from a function