I want to look for the string "methodname(", but I am unable to escape the "(". How can I get
grep methodname( *
or
ack-grep methodname( *
to work?
I want to look for the string "methodname(", but I am unable to escape the "(". How can I get
grep methodname( *
or
ack-grep methodname( *
to work?
Try adding a
\
before the(
.Small demo:
Enclosing the pattern in single or double quotes also works:
There's two things interpreting the
(
: the shell, andack-grep
.You can use
''
,""
, or\
to escape the(
from the shell, e.g.grep
uses a basic regular expression language by default, so(
isn't special. (It would be if you usedegrep
orgrep -E
orgrep -P
.)On the other hand,
ack-grep
takes Perl regular expressions as input, in which(
is also special, so you'll have to escape that too.