bash - 删除同一行中的重复单词?
问题描述
我想删除同一行中的重复单词并保存句子而不更改非重复单词的位置
我的文本.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
解决方案
推荐阅读
- vapor - 将静态网页添加到 Vapor 服务器
- mysql - SQL 插入用户上次活动的结束日期
- android - 使用 expo-av 在内置的 Expo 应用程序(iOS 和 Android)的独立版本上无法播放声音
- google-app-engine - 如何从 GCP 的托管 ssl 迁移到不同的服务
- python - Python中的uint8_t翻转?什么是最好或最优雅的方式?
- angular - rxjs:条件取数
- node.js - 如何使用 KEY 值的外部引用创建简单的 JSON 对象?
- javascript - 使用FormData通过数据表单json填充html表单
- reactjs - 如何从 react-leaflet v2 重写到 v3?
- c# - 体素网格边缘的奇怪阴影