Copy a Bash array with empty elements

前端 未结 2 1708
轮回少年
轮回少年 2021-01-12 03:04

I\'m having problems in bash (ver 4.2.25) copying arrays with empty elements. When I make a copy of an array into another variable, it does not copy any empty elements alon

2条回答
  •  盖世英雄少女心
    2021-01-12 03:45

    Starting with Bash 4.3, you can do this

    $ alpha=(bravo charlie 'delta  3' '' foxtrot)
    
    $ declare -n golf=alpha
    
    $ echo "${golf[2]}"
    delta  3
    

提交回复
热议问题