I needed to reverse the order of blank-separated words. GNU tac comes to mind and has an -s-option. which lets you set the separator:
-s, --separator=STRING use STRING as the separator instead of newline So I tried:
$ echo -e A B C D E F | tac -s' ';echo F E D C B A $ echo -e A B C D E F | tac -s' ' | tr ' ' '-';echo F E-D-C-B-A- $ where the final echo is to have the next prompt on a separate line and the tr ' ' '-' is to see any invisible blanks at the end of the output lines.
What irritates me is the newline after the "F" in the output.
Looks like a bug to me, is it?
While writing this question and looking at the suggestions for similar questions (a very good feature), I saw Reversing a file line-wise and character-wise and learned about rev, which is exactly what I wanted.
Still, for tac, is it a bug or a feature?