Sorting and removing duplicate words in a line

前端 未结 7 1074
陌清茗
陌清茗 2020-12-03 06:50

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

7条回答
  •  执念已碎
    2020-12-03 07:17

    The shell was built to parse [:blank:] seperated word lists already. Therefore the use of xargs is completely redundant. The "unique" stuff can be done but its just easier to use sort.

    echo $(printf '%s\n' zebra ant spider spider ant zebra ant | sort -u)

提交回复
热议问题