I have a simple string:
foo bar boo you too
I'm looking for an easy way in bash on the command line (not in a script) to take this string in via a pipe or input redirection and convert it to
foo
bar
boo
you
too
I have a simple string:
foo bar boo you too
I'm looking for an easy way in bash on the command line (not in a script) to take this string in via a pipe or input redirection and convert it to
foo
bar
boo
you
too
You could use 'tr' to translate the space to a new line:
~$ echo 'foo bar boo you too' | tr ' ' '\n'
foo
bar
boo
you
too
A working solution using grep
and regular expressions:
echo "foo bar boo you too" | grep -oE "[a-z]+"
[in Bash] lit.
$ echo "foo bar boo you too" | ( read -a A; printf '%s\n' "${A[@]}"; )
foo
bar
boo *
you
too