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>




Reply via email to