linux shell数组操作

  1. 定义数组
    [chengmo@centos5 ~]$ a=(1 2 3 4 5)
    [chengmo@centos5 ~]$ echo $a
    1
    [chengmo@centos5 ~]$ a=([1]=aaa [2]=bbb [c]=ccc)
    [chengmo@centos5 ~]$ echo ${a[c]}
    ccc
    [chengmo@centos5 ~]$ b[1]=100
    [chengmo@centos5 ~]$ echo ${b[1]}
    100
    [chengmo@centos5 ~]$ a="one two three"  # echo ${array[0|@|*]},把array变量当作数组来处理,但数组元素只有字符串本身

    继续阅读