I would write it this way in a command line prompt. It could be, of course, more compressed, but for clarity’s sake:
~$ text='You can do this, but the newlines will be embedded in the variable, so it won’t be a single line'
~$ array=$(echo $text | cut -d' ' -f 1-)
~$ for x in ${array[@]}; do echo $x ; done
Here is a one liner:
~$ echo $text | tr ' ' '\n'
Output:
You
can
do
this,
but
the
newlines
will
be
embedded
in
the
variable,
so
it
won’t
be
a
single
line
Or, for a sorted output:
~$ echo $text | tr ' ' '\n' | sort
Output:
a
be
be
but
can
do
embedded
in
it
line
newlines
single
so
the
the
this,
variable,
will
won’t
You