删除同一行中的重复单词?

时间:2021-01-23 09:07:13

标签: bash shell command-line tr uniq

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

我的文本.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

0 个答案:

没有答案