I have the following string:
-----BEGIN 1_1 CERTIFICATE-----
The following sequence does not match the hyphens:
grep -- "[A-Z\-\_]" file
When I remove \_
the hyphens are matched:
grep -- "[A-Z\-]" file
If I remove the backslash I get grep: Invalid range end
. Also it doesn't matter if I use -E/egrep
or not - I get the same result.
What is the reason for that behavior?
grep '-'
. – jesse_b May 10 '18 at 17:37"[A-Z\-\_]"
not matching hyphens? – manifestor May 10 '18 at 17:47grep '[A-Z_-]'
– jesse_b May 10 '18 at 17:50\-
at the end. And why[A-Z\-\_]
is not working. – manifestor May 10 '18 at 17:54grep: Invalid range end
on my system. – manifestor May 10 '18 at 18:05A-Z
is a range specifying any uppercase letter between a and z). – jesse_b May 10 '18 at 18:16