Bash 可变序列扩展(字母范围)
Bash variable sequence expansion (letter range)
给定几个我想连接的变量:
# 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}}"
这应该有效
$ 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 ' ' ','
给定几个我想连接的变量:
# 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}}"
这应该有效
$ 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 ' ' ','