I want to find aaa, bbb etc I've tried :
grep -E [a-z]\{3\} 1.txt
but this even prints abc
You can use references to capturing groups:
[/tmp] cat test.txt
aaa
bbb
abc
aab
bbc
[/tmp] grep -E "([a-z])\1{2}" test.txt
aaa
bbb
\1 refers to the stuff captured by ([a-z]) (a single letter, in your case), so the regex looks for a single letter followed by the same letter two more times.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With