I'm pretty inexperienced with grep behavior. I have a bunch of XML files containing lines like this:
<identifier type="abc">abc:def.ghi/g1234.ab012345</identifier>
<identifier type="abc">abc:def.ghi/g5678m.ab678901</identifier>
I wanted to get the part of the identifier after the slash and create a regex using RegexPal :
[a-z]\d{4}[a-z]*\.[a-z]*\d*
He highlights everything that I wanted. Fine. Now when I run grep in the same file, I am not getting any results. And, as I said, I really know little about grep, so I tried all the different combinations.
grep [a-z]\d{4}[a-z]*\.[a-z]*\d* test.xml
grep "[a-z]\d{4}[a-z]*\.[a-z]*\d*" test.xml
egrep "[a-z]\d{4}[a-z]*\.[a-z]*\d*" test.xml
grep '[a-z]\d{4}[a-z]*\.[a-z]*\d*' test.xml
grep -E '[a-z]\d{4}[a-z]*\.[a-z]*\d*' test.xml
What am I doing wrong?
source
share