In this command, I want to extract strings that are like *.com or *.net, where * is not a dot. I wrote this:
grep -P -E '^[^.]+\.com$ |^[^.]+\.net$' example.csv
I get this error:
grep: conflicting matchers specified
Can you clarify?
You can't use both PCRE (
-P) and Extended Regular Expressions (
-E) at the same time. In this case, it seems as if you don't use PCRE expressions at all, so you could just drop the
-P. You also can't expect to match a space after
Combining most of the expression into a shorter one:
grep -E '^[^.]+\.(com|net)$'
grep -E -x '[^.]+\.(com|net)'
-x option will cause
grep to only match complete lines.
The expression matches a non-zero number of non-dot characters, followed by a dot and then either