Shell 遍历数组的方法

数组的申明方式

array=(element1 element2 element3 .... elementN) 

数据读取

#echo ${array[0]}  
#echo ${array[index]} 

数据遍历

for data in ${array[@]}  
do  
    echo ${data}  
done  

参考资料:

1、Linux Shell中的数组及遍历
https://blog.csdn.net/redhat456/article/details/6068409

2、Shell编程中的数组定义、遍历
https://www.coder4.com/archives/3853

猜你喜欢

转载自blog.csdn.net/heatdeath/article/details/80438430