Merging two arrays in Bash

后端 未结 5 1664
梦如初夏
梦如初夏 2020-12-13 13:39

I have the following situation, two arrays, let\'s call them A( 0 1 ) and B ( 1 2 ), i need to combine them in a new array C ( 0:1 0:2 1:1 1:2 ), the latest bit i\'ve come u

5条回答
  •  庸人自扰
    2020-12-13 14:29

    Here is how I merged two arrays in Bash:

    Example arrays:

    AR=(1 2 3) BR=(4 5 6)

    One Liner:

    CR=($(echo ${AR[*]}) $(echo ${BR[*]}))

提交回复
热议问题