数组循环
#!/bin/bash
city[1]="HongKong"
city[2]="Beijing"
city[3]="shanghai"
for i in ${city[*]}
do
echo $i
done
#!/bin/bash
city=(Nanjing Atlanta Massachusetts Marseilles)
echo ${city[*]:0} #打印从第0个开始
echo ${city[*]:1} #打印 从第一个开始
echo ${city[*]:0:2} #打印 从第0个开始 2个元素
echo ${city[*]#M*a}
echo ${city[*]##M*a}
echo ${city[*]/M*s/Year} #替换,第一次匹配
echo ${city[*]//M*s/Year} #替换,全部替换
阅读(1670) | 评论(0) | 转发(0) |