Here's a version that doesn't use "here string" and so doesn't create temporary files.
#!/bin/bash shopt -s lastpipe string="Los Angeles, London, Belfast, New York" echo "${string/, /,}" | readarray -d, -t arrayA echo ${arrayA[0]} echo ${arrayA[1]}
Here's a version that doesn't use "here string" and so doesn't create temporary files.
Also, the lastpipe option runs the readarray in the context of the current process.