linux - 从文本文件中仅删除顺序重复?
问题描述
我只是一揽子删除重复项没有问题- sort -u input.txt > output.txt 很容易做到这一点。但我只想删除顺序的、后续的重复项,我不知道该怎么做。这是一个例子:
输入:
One
Two
Two
Three
Four
Five
Five
Six
Seven
Seven
Seven
Three
Three
Two
One
输出:
One
Two
Three
Four
Five
Six
Seven
Three
Two
One
有没有人想出一个简单的 bash 序列来做到这一点,或者知道一个 *NIX 命令行实用程序可以做到这一点?
编辑:澄清了这个例子。
解决方案
推荐阅读
- javascript - socket.io 客户端连接到服务器但不通信
- ios - 如何将 TapGestureRecogniser 分配给用户绘制的线条
- python - 将密码保存到txt文档并实现一个列表
- mysql - 建模多对多关系的正确方法
- arrays - Ruby:0 处的错误元素类型符号(预期数组)
- python - 如何将自定义函数应用于 PyTorch 中矩阵中的特定列
- php - 将下拉选择的值传递给同一表单内的查询
- ngrok - ngrok 未连接到本地服务器
- algorithm - GPS 误差在短时间内是否一致?
- reactjs - 将 for/map 分成两个独立组件的原因是什么?