数组是特殊的变量,普通变量可以支持切片
a=sum_abc.mail.cn
echo ${a:5:3}
普通数组只能使用整数做为数组索引,关联数组可以使用字符串做为数组索引
普通数组
apples=(linux shell wps fox wp)
linux shell wps fox wp
0 1 2 3 4 索引(下标)
关联数组
declare -A info #shell默认不支持关联数组,需要使用-A手动声明
info=([name]=huya [sex]=w [age]=20 [skill]=fun)
echo ${info[name]}
echo ${info[sex]}
原文:https://www.cnblogs.com/xiaofeng666/p/12244879.html