2

I am trying to use ack to search (in Haskell files) for +|+

I looked at ack-grep: chars escaping but this doesn't help

On Mac OS X 10.6 I get the following responses:

$ ack -Q +|+
-bash: +: command not found
Missing option after +
ack: See ack --help, ack --help-types or ack --man for options

$ ack \+\|\+
Unknown option: |
ack: See ack --help, ack --help-types or ack --man for options

$ ack [+][|][+]
-bash: ][+]: command not found
ack: Invalid regex '[+][':
  Unmatched [ in regex; marked by <-- HERE in m/[+][ <-- HERE /

$ ack \Q+|+\E
-bash: +E: command not found

That's basically all the suggestions in the Q&A listed above

4

2 回答 2

3

这应该按预期工作:

$ ack "\+\|\+"

(根据您的评论编辑为正确。未引用的管道是“或”。)

于 2013-04-25T09:35:04.800 回答
0

-Q引用搜索字符串中的所有内容。

ack --haskell -Q '+|+'

这比

ack --haskell "\+\|\+"
于 2013-05-16T17:20:09.680 回答