标签:Opens nbsp tac 示例 ash das linu 长度 declare
[root@wshile ~]# books=(linux shell awk openstack docker)
[root@wshile ~]# echo ${books[1]}
shell
[root@wshile ~]# echo ${books[@]} // 查看所有变量
linux shell awk openstack docker
[root@wshile ~]# echo ${#books[@]} // 查看变量长度
5
[root@wshile ~]# echo ${!books[@]} // 获得数组的所有索引
0 1 2 3 4
shell默认不支持多维,需要声明
declare -A 变量名
示例
[root@wshile ~]# declare -A info
[root@wshile ~]# info=([name]=wsl [sex]=n [age]=18)
[root@wshile ~]# echo ${info[name]}
wsl
标签:Opens nbsp tac 示例 ash das linu 长度 declare
原文地址:https://www.cnblogs.com/Wshile/p/12826536.html