shell 数组的几种形式汇总:1.HOSTS=() while read line
do
HOSTS[${#HOSTS[@]}]=$line
done < $hostfile
2.for i in "${A[@]}"; do echo $idone 3.
INFOS="
A,
B,
C,
D
"
for INFO in $INFOS
do
AREA=`echo $INFO | awk -F ',' '{print $1}'`
echo $AREA
done
4.#!/bin/bash
ary="hyves nk us it tr ae"
for i in $ary;
do
echo $i
done
5.#!/bin/bash ary=("hyves" "nk" "us" "it" "tr" "ae") for i in ${ary[@]}; do echo $i done6. #!/bin/bash arr=("hyves" "nk" "us" "it" "tr" "ae") len=${#arr[@]} for((i=0;i