寻找独特的台词 [英] Find unique lines

查看:92
本文介绍了寻找独特的台词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何找到唯一的行并从文件中删除所有重复项? 我的输入文件是

How can I find the unique lines and remove all duplicates from a file? My input file is

1
1
2
3
5
5
7
7

我希望结果是:

2
3

sort file | uniq不会执行此工作.将一次显示所有值

sort file | uniq will not do the job. Will show all values 1 time

推荐答案

uniq具有您需要的选项:

   -u, --unique
          only print unique lines

$ cat file.txt
1
1
2
3
5
5
7
7
$ uniq -u file.txt
2
3

这篇关于寻找独特的台词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆