Bash indirect array addressing?

后端 未结 3 2118
离开以前
离开以前 2020-11-28 09:55

Suppose I have some bash arrays:

A1=(apple trees)
A2=(building blocks)
A3=(color television)

And index J=2, how

3条回答
  •  误落风尘
    2020-11-28 10:42

    I've already found a resolution, this can be done by:

    $ Aref=A$J
    $ echo ${!Aref}
    building
    $ Aref=A$J[1]
    $ echo ${!Aref}
    blocks
    $ Aref=A$J[@]
    $ echo "${!Aref}"
    building blocks
    

提交回复
热议问题