0

I would like to display the lines on text if 3 digits repeated in same line

with a condition applied for 3 digits repeat.

Input

410202410
203103903
555710294473555

so 410 and 555 repeated

Output

410202410
555710294473555

how to handle this through sed or awk?

I would like also to apply the same only on digits before first comma.

such as 410202410,11,2017,109

2

POSIXly:

grep '\([0-9]\{3\}\).*\1'

Would print the lines that contain 3 decimal digits followed by a sequence of 0 or more characters followed by the same 3 digits.

To restrict that pattern before the first comma:

grep '^[^,]*\([0-9]\{3\}\)[^,]*\1'
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.