Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I want to grep the pattern like "1-10","10-20","1-9"(without double quotes) with the following code:
grep '[[:digit:]]\-[[:digit:]]' mydoc
It is ok to grep "1-9" but I can't figure out how to grep other two patterns!
The minus needs no masking. + allows multiple occurrences.
egrep '[0-9]+-[0-9]+' mydoc
Add a comment
grep -E '[[:digit:]]+-[[:digit:]]+' mydoc
grep -E '[[:digit:]]{1,2}-[[:digit:]]{1,2}' mydoc
?
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.