The sort command lets me put lines in alphabetical order and remove duplicate lines. I need something similar that can sort the words on a single line, put them in order, and remove any duplicates. Is there a command for this?
E.g.:
zebra ant spider spider ant zebra ant
Changes to:
ant spider zebra
There is no space before the first word or after the last word.
This works for me:
You can transform a list of words in a single row to a single column with
xargs -n1, usesort -uand transform back to a single row withxargs.