Why can’t I match the string
"1234567-1234567890"
with the given regular expression
\d{7}-\d{10}
with egrep from the shell like this:
egrep \d{7}-\d{10} file
?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
egrepdoesn’t recognize\dshorthand for digit character class, so you need to use e.g.[0-9].Moreover, while it’s not absolutely necessary in this case, it’s good habit to quote the regex to prevent misinterpretation by the shell. Thus, something like this should work:
See also
egrepmini tutorialReferences
grep,ed,sed,egrep,awk,emacsgrepvsegrepvs other regex flavors