I am trying to write a command to grep the number of occurrences in a string, but my string is "ATATAT" and I want to grep "ATAT". I am expecting to get 2 outputs when I use command I get only 1.
echo "ATATAT" |grep -o "ATAT"
I have tried surrounding the string with ** but still it only matches one pattern.
The simplest way - make Python do it for you:
python -c "import re; print(re.findall(r'(?=(ATAT))', 'ATATAT'))"
['ATAT', 'ATAT']
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