首页 > 编程语言 > 详细

循环打印数组,并统计个数shell脚本

时间:2016-05-10 18:13:32      阅读:170      评论:0      收藏:0      [点我收藏+]

                    使用Shell循环打印数组                    


[root@slavedb array]# cat a.sh
#!/bin/bash
array=(
freddy
freddie
tang
sheng
wei
)
for ((i=0;i<${#array[@]};i++));do
        echo "This is num $i,then content is ${array[$i]}"   #$i是下标
done
echo "-----------------"
echo "array len:${#array[@]}"

 

循环打印数组,并统计个数shell脚本

原文:http://www.cnblogs.com/tangshengwei/p/5478485.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!