Definition Method
Subscript array direct assignment
#! /Bin/basharr [0] = "one" arr [1] = "two" arr [2] = "three" for num in $ {arr [*]} doecho $ numdone
Sequential assignment of parentheses
Arr = ("four" "five" "six") for num in $ {arr [*]} doecho $ numdon
Execution result join array premise: associated array requires syntax declaration, refer to: http://blog.csdn.net/zinss26914/article/details/8675058
Declare-A array_name
Assignment
#! /Bin/bashdeclare-A arrarr ["name"] = "wangzhengyi" arr ["sex"] = "boy" arr ["Age"] = "25" for Param in $ {arr [*]} doecho $ paramdone
Run the. array length and read array length command.
Use $ {# array name [* or @]} to obtain the array length.
Example array value reading command
Use $ {subscript array name [subscript]} or $ {join array [Key]}
Note: If the subscript is * or @, you can obtain the sample array key reading command for the entire array.
$ {! Array name [* or @]}
After the example, keep learning and summarize it. In the future, some shell knowledge will be updated frequently, which is commonly used for O & M!