鉴于我想要连接几个变量:
# valid
COUNTRIES_A="ad,af,ai,ag,al,am,ao,ar,ax,az,"
COUNTRIES_B="ba,bd,bf,bh,bi,bj,bn,br,bt,bw"
COUNTRIES="${COUNTRIES_A},${COUNTRIES_B}"
是否有一个序列扩展可以更优雅地实现这一目标?
# invalid but essentially ...
COUNTRIES="${COUNTRIES_{A..B}}"
答案 0 :(得分:0)
这应该有效
$ echo $COUNTRIES_{A..B}
ad,af,ai,ag,al,am,ao,ar,ax,az ba,bd,bf,bh,bi,bj,bn,br,bt,bw
所以,你可以做到
$ COUNTRIES=$(echo $COUNTRIES_{A..B})
如果你想要一个完整的csv列表,请管道到tr ' ' ','