35

Text file:

1 1
2 2
3 3
1 1

I want to catch 1 1 as duplicated

RubioRic
  • 2,406
  • 4
  • 27
  • 34
Kalin Borisov
  • 1,030
  • 1
  • 12
  • 22

3 Answers3

105

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
  • 59,844
  • 20
  • 139
  • 166
2

One way using GNU awk:

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

Results:

1 1
Steve
  • 45,652
  • 12
  • 89
  • 100
1

You can use it easily:

sort -u file.txt

OR

awk '!x[$0]++' file.txt
MLSC
  • 5,584
  • 7
  • 49
  • 85