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
grep -E '[[:digit:]]+-[[:digit:]]+' mydoc
grep -E '[[:digit:]]{1,2}-[[:digit:]]{1,2}' mydoc
?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.