脚本代码如下
!/bin/bash
city=(nanjing beijing jinan zibo linyi)
echo “city[0]=
city[0]”echo“city[1]=
c
i
t
y
[
0
]
”
e
c
h
o
“
c
i
t
y
[
1
]
=
{city[1]}”
echo “city[2]=
city[2]”echo“city[3]=
c
i
t
y
[
2
]
”
e
c
h
o
“
c
i
t
y
[
3
]
=
{city[3]}”
echo “city[4]=
city[4]”echo“city[5]=
c
i
t
y
[
4
]
”
e
c
h
o
“
c
i
t
y
[
5
]
=
{city[5]}”
解析:
定一个city数组 并对数组的变量进行了引用