📜  bash 循环数组 - Shell-Bash 代码示例

📅  最后修改于: 2022-03-11 14:49:45.606000             🧑  作者: Mango

代码示例4
#!/bin/bash
## declare an array variable
declare -a array=("one" "two" "three")

# get length of an array
arraylength=${#array[@]}

# use for loop to read all values and indexes
for (( i=0; i<${arraylength}; i++ ));
do
  echo "index: $i, value: ${array[$i]}"
done