,如何在Bash中的数组中转换为字符串:
details="cl roo,dara shi,GD leader, is the man,YG FAMILY"
这是我的代码:
IFS="[a-z],[a-z]" read -r -a details_list <<< "$details"
迭代数组时的预期输出:
cl roo
dara shii
GD leader, is the man
YG FAMILY
迭代数组时的实际输出:
cl roo
dara shii
GD leader
is the man
YG FAMILY
答案 0 :(得分:0)
这应该有效:
details="cl roo;dara shi;GD leader, is the man;YG FAMILY"
IFS=';' read -r -a array <<< "$details"
echo "${array[2]}" -> GD leader, is the man