GNU grep 2.20 disallows the use of an unmatched right parenthesis in an extended regular expression:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $ echo ')' | grep -E ')' grep: Unmatched ) or \) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Other greps I've tried (AST grep 2014-01-06, BusyBox 1.22.1 grep, BSD grep 2.5.1-FreeBSD on OS X 10.8, /usr/xpg4/bin/grep on Solaris 11.2-beta) accept ')' as a valid ERE. POSIX apparently allows an unmatched right parenthesis in this context, as section 9.4.3 (ERE Special Characters; http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_04_03) states: "The <right-parenthesis> shall be special when matched with a preceding <left-parenthesis>, both outside a bracket expression." and in section 9.5.1 (BRE/ERE Grammar Lexical Conventions) (http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_05_01), the description of the "SPEC_CHAR" token contains the following exception: "The close-parenthesis shall be considered special in this context only if matched with a preceding open-parenthesis." -- Nathan Weeks IT Specialist USDA-ARS Corn Insects and Crop Genetics Research Unit Crop Genome Informatics Laboratory Iowa State University http://weeks.public.iastate.edu/