Definition of the array:
Array name = (element 1 element 2 element N) # A pair of parentheses indicates an array, and the elements of the array are separated by a "space" symbol.
Example: myarray= (1 3 5 7 9) # Note the method defined, parentheses, commas.
Define an array: myarray= (1 2 3 4 5)
Reads an element of an array: Echo ${myarray[subscript value]} # Note the array name must be enclosed in {}, and the subscript value will be numbered starting with 0.
Assignment of array elements: myarray[subscript value] = XXX
Show all elements of an array: Echo ${myarray[*]}
Get the length of the array (number of elements): Echo ${#array [@]} or echo ${#array [*]}
Delete an array element: unset myarray[Subscript value]
----------------------------------------------------------------------------------------------------------
The format of the function definition:
# function can be omitted, note () internal without any parameters, if necessary parameters, directly at the time of the call directly with the parameters
#向函数传递参数就像在一般脚本中使用特殊变量 $1, $2 ... $9
#函数取得所传参数后, it's a good idea to first reset the arguments in the function to save the argument.
Function name ()
{
Command 1
Command 2
. . .
}
Shell programming (vi)---------arrays and functions