Sample Header Ad - 728x90

tac-command is it a bug or a misinterpretation of the manual?

4 votes
2 answers
950 views
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 https://unix.stackexchange.com/q/598611/268339 and learned about rev, which is exactly what I wanted. Still, for tac, is it a bug or a feature?
Asked by Gyro Gearloose (455 rep)
Jul 23, 2025, 09:17 AM
Last activity: Jul 29, 2025, 05:52 PM