41

Text file:

1 1
2 2
3 3
1 1

I want to catch 1 1 as duplicated

RubioRic
  • 2,442
  • 4
  • 28
  • 35
Kalin Borisov
  • 1,091
  • 1
  • 12
  • 23

3 Answers3

111

Your question is not quite clear, but you can filter out duplicate lines with uniq:

sort file.txt | uniq

or simply

sort -u file.txt

(thanks RobEarl)

You can also print only repeating lines with

sort file.txt | uniq -d
Lev Levitsky
  • 63,701
  • 20
  • 147
  • 175
3

One way using GNU awk:

awk 'array[$0]++' file.txt 

Results:

1 1
Steve
  • 51,466
  • 13
  • 89
  • 103
1

You can use it easily:

sort -u file.txt

OR

awk '!x[$0]++' file.txt
MLSC
  • 5,872
  • 8
  • 55
  • 89