Home > front end >  extract numbers from repeated block
extract numbers from repeated block

Time:04-27

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.

CodePudding user response:

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

CodePudding user response:

Suggesting to try:

 sort -n -u input > output
  • Related