I have a command which outputs a randomly ordered set on words. My goal is, ultimately, to get a sorted list. I'm trying to find a way to do this that can be done with a single command. I know that if the output is on multiple lines, it can be sorted by piping it to sort, such as
$ echo "foo
> bar
> baz" | sort
bar
baz
foo
So is there a simple command that I can use to split a string like "foo bar baz" into separate lines, so I can accomplish my goal with echo "foo bar baz" | magic_string_splitter | sort
edit: bonus, the list actually contains some extra output at the end that would be great to ignore. so for instance, the output of my command might actually be like this
$ print_words
foo bar baz are your words
But I'd still like the final result to just be
bar
baz
foo
We can totally strip off and ignore the "are your words" at the end.
IFSto a whitespace" are your words"