zhushixia 2020-05-04
[ ~]# books=(linux shell awk openstack docker)
[ ~]# echo ${books[1]}
shell
[ ~]# echo ${books[@]} // 查看所有变量
linux shell awk openstack docker
[ ~]# echo ${#books[@]} // 查看变量长度
5
[ ~]# echo ${!books[@]} // 获得数组的所有索引
0 1 2 3 4shell默认不支持多维,需要声明
declare -A 变量名
示例
[ ~]# declare -A info
[ ~]# info=([name]=wsl [sex]=n [age]=18)
[ ~]# echo ${info[name]}
wsl