从重复块中提取数字

发布于 2025-01-24 06:54:57 字数 290 浏览 2 评论 0原文

我有一个文本文件,该文件包含重复 NOS的块,如下所示(使用> symbl),我只想提取一次重复值。

Input

>
1
2
3
4
10
100
>
1
2
3
4
10
100

expected output

1
2
3
4
10
100

我尝试了脚本

#!/bin/sh
uniq -d input > output

,但是它给出了与输入相同的输出。

I have a text file that contain repeated block of nos as given below(with > symbol) and I want to extract repeated values only once.

Input

>
1
2
3
4
10
100
>
1
2
3
4
10
100

expected output

1
2
3
4
10
100

I tried script

#!/bin/sh
uniq -d input > output

but it gives output same as input.can anybody suggest a solution on this.Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

云淡风轻 2025-01-31 06:54:57

您需要先对其进行排序。尝试一下

排序输入| UNIQ -D

或如果要将其保存为文件

排序输入| uniq -d>输出

you need to sort it first. Try this

sort input | uniq -d

or if you want to save it as a file

sort input | uniq -d > output

没有伤那来痛 2025-01-31 06:54:57

建议尝试:

 sort -n -u input > output

Suggesting to try:

 sort -n -u input > output
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文