linux - 如何从Linux中的文件中获取唯一出现

标签 linux shell grep uniq

我有一个 data.txt 文件如下

1
1
100
100
1
1
1

当我尝试时,

more 'data.txt|uniq' 

连续多次出现的uniq值

1
100
1

有没有办法,我可以得到这样的结果

1
100

提前致谢

最佳答案

尝试执行

$排序-u数据.txt

描述:

根据 uniq 的手册页

Note: 'uniq' does not detect repeated lines unless they are adjacent. You may want to sort the input first, or use 'sort -u' without 'uniq'.

你可以通过执行阅读联机帮助页

$ 男人独特

关于linux - 如何从Linux中的文件中获取唯一出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16784957/

相关文章:

linux - 如何找到链接到重命名卷的所有符号链接(symbolic link)?

等待线程可以休眠吗?

python - 如何最好地将数据流式传输到 IP 地址?

linux - 在 Bash 脚本中,函数的第二个参数未按预期处理

mysql查询从同一个表中选择两列

linux - 在 drupal 语言中 : grep and pipe - list all the findings to avoid overhead & serverperformance issues

linux - 如何从内置 bin 重定向以执行 AppImage?

linux - 使用 shell 脚本和标准输入创建多个帐户

linux - 按时间排序访问日志

linux - 数 = 'ps -ef | grep -v grep| grep BatchName| wc -l'