To search for a parenthesis character, pass backslash+parenthesis to ack.
Both backslash and parentheses are special in the shell, so you need to quote them when you're entering them in a shell script or on the command line. The simplest form of quoting is with single quotes: this tells the shell to pass everything through literally except single quotes themselves.
You can also use backslashes to protect special characters from shell expansion, but it tends to be less readable:
The first backslash quotes the second one in the shell, so that the first character of the argument to
\. The third backslash quotes the parenthesis, so the second character of the argument to
(. Like in the case with single quotes above, the argument that
ack sees is the two-character string
ack ( doesn't work because the shell sees an opening parenthesis and treats it as shell syntax.
ack \( doesn't work because the shell passes
( as the argument to
ack, and ack interprets the parenthesis in the regular expression as indicating the start of a group.