bash 提供了一维数组的功能,Suzuki索引从0开始,没有大小限制。
数组的创建:
数组的读取:
例:
root@VM_0_3_centos ~]# A[1]=huang [root@VM_0_3_centos ~]# A[2]=wei [root@VM_0_3_centos ~]# echo ${A[1]},${A[2]} huang,wei [root@VM_0_3_centos ~]# echo ${A[1]}:${A[2]} huang:wei [root@VM_0_3_centos ~]# echo ${A[*]} huang wei [root@VM_0_3_centos ~]# echo ${A[@]} huang wei [root@VM_0_3_centos ~]# B=(huang wei) [root@VM_0_3_centos ~]# echo ${B[0]},${B[1]} huang,wei [root@VM_0_3_centos ~]# echo ${#B[*]} 2 [root@VM_0_3_centos ~]# echo ${#B[0]} 5
原文:https://www.cnblogs.com/icase/p/11104767.html