I'm trying to convert the output of a command like echo -e "a b\nc\nd e"
to an array.
X=( $(echo -e "a b\nc\nd e") )
Splits the input for every new line and whitespace character:
$ echo ${#X[@]}
> 5
for i in ${X[@]} ; do echo $i ; done
a
b
c
d
e
The result should be:
for i in ${X[@]} ; do echo $i ; done
a b
c
d e
readarray -t ARRAY < <(COMMAND)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With