How do you ack for a file that contains two or more phrases/words?

@kirkbauer suggested

ack phrase2 `ack -l phrase1`

and that will indeed work. I prefer to use the $() syntax instead of ``` ` syntax

ack phrase2 $(ack -l phrase1)

With the release of ack 2.0, you get the -x switch so that you can do this:

ack -l phrase1 | ack -x phrase2

The -x tells ack to take the list of files to read from STDIN.


This should do the trick: perform first ack, get file list, look for second set of files.

ack phrase2 `ack -l phrase1`