質問

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

役に立ちましたか?

解決

This should work as intended:

$ ack "\+\|\+"

(Edited to be correct per your comments. Unquoted pipe is 'or'.)

他のヒント

The -Q will quote everything in your search string.

ack --haskell -Q '+|+'

which is easier than

ack --haskell "\+\|\+"
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top