What i am looking for is to find a grep command to find same number digits in a 4 digit sequence.
For example
1111
1234
5678
1231
2233
4546
output should be
1111
1231
2233
4546
Ive tried grep "\([0-9]\)\\1"
but that doesnt catch numbers like 1231 or 4546
thanks
CodePudding user response:
Using grep
$ grep '\([0-9]\).*\1' file
1111
1231
2233
4546
Match interger character in any position in the first cature group within the parenthesis. If the number captured is found again as a last occurance with the back reference \1
, then a match is made.