1.

数组下标从0开始

#定义数组
[root@study ~]# a=(a b c)
#输出所有元素
[root@study ~]# echo ${a[@]}
a b c
#输出所有元素
[root@study ~]# echo ${a[*]}
a b c
#输出所有元素下标
[root@study ~]# echo ${!a[*]}
0 1 2
#输出第一个元素
[root@study ~]# echo ${a[0]}
a
#添加元素
[root@study ~]# a[3]=d
[root@study ~]# echo ${a[@]}
a b c d
#添加多个元素
[root@study ~]# a+=(e f g)
[root@study ~]# echo ${a[@]}
a b c d e f g
#删除第一个数组元素,会保留数组下标
[root@study ~]# unset a[0]
[root@study ~]# echo ${!a[@]}
1 2 3 4 5 6
#获取数组长度
[root@study ~]# echo ${#array[*]}
10