user5051184
user5051184

Reputation: 13

How to do this grep regex

I am trying to grep all lines that have two repeating numbers.

At first I tried grep "[0-9][0-9]" but this is just asking for lines with two numbers. How do I make it look for two numbers that are the same?

Upvotes: 1

Views: 24

Answers (1)

rurouni88
rurouni88

Reputation: 1173

grep -E '([0-9])\1+' <FILENAME>

The '[0-9]' is self-explanatory.

The '\1+' looks for 2 or more occurrences of the same character specified within the grouping

Upvotes: 2

Related Questions