bash操作数组
#!/bin/bash declare -a colors; echo "Enter your favorite colors (septated from each other by space)."; read -a colors; #get the length of array element_count=${#colors}; index=0;
#all over the array. echo "------all over the array------";
#the No1. method.
echo "---the No1. method ----";
while
do
echo ${colors};
let "index = $index + 1";
done
#the No2 method. echo "----the No2 method----"; for item in ${colors} do echo $item; done
#remove items of array echo "-----remove items of array-----"; #remove the first item of colors array. unset colors; echo ${#colors}; #remove all items of colors array,there are three methods . #unset colors; unset colors ; #unset colors; echo ${#color};