I am trying to convert the output of a command like echo -e "ab\nc\nd e"
to an array.
X=( $(echo -e "ab\nc\nd e") )
Separates the input for each new line and space 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 ab c de
Thomas jung
source share