首页 > 解决方案 > 删除同一行中的重复单词?

问题描述

我想删除同一行中的重复单词并保存句子而不更改非重复单词的位置

我的文本.txt

Linux systems with unix systems 
shell script is the best script 

需要的输出

Linux systems with unix 
shell script is the best 

我使用了这个脚本:


    tr ' ' '\n' <my_text.txt |  xargs -n1 | sort -u | xargs

但输出与输入数据相同:

linux systems with unix 
shell script is the best

有什么建议可以为这个例子找到完美的解决方案吗?
注意:我不使用awk

标签: bashshellcommand-linetruniq

解决方案


推荐阅读