Subject: bug#17799: grep 2.5.4 ignoring parts of expression

From: Norihiro Tanaka <[email-masked]>
Date: Thu, 19 Jun 2014 00:36:41 +0900

If you don't specify any options, grep regards a pattern as BRE.

http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html#tag_09_03

(', `)' and `?' are treated as normal character in BRE.  If you expect
that they are treated as special character, you must escape them with
backslash.

BTW, I see you want to use ERE.

http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html#tag_09_04

If so, you must specify -E option.  I test below on Fedora 20.

$ cd /usr/include/c++/4.8.2
$ grep -E "#include <(bits/)?random(\.h)?>" * 2>/dev/null
$ grep "#include <(bits/)?random(\.h)?>" * 2>/dev/null
random:#include <bits/random.h>