-1

in Bash, how can i transform below string in an array in Bash:

details="cl roo,dara shi,GD leader, is the man,YG FAMILY"

This is my code:

IFS="[a-z],[a-z]" read -r -a details_list <<< "$details"

Expected output when array is iterated:

cl roo
dara shii
GD leader, is the man
YG FAMILY

Actual Output when array is iterated:

cl roo
dara shii
GD leader
is the man
YG FAMILY

1 Answers1

0

This should works:

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