0

Suppose I want to find all files in the current directory that have at least one occurence of the name Peter and at least one occurence of the name James.

I can find a list of those files by doing ack-grep -l Peter * | xargs ack-grep -l James as suggested in this thread.

But how can I also show the lines where these words occur? Simply doing ack-grep Peter * | xargs ack-grep James does not return the expected output.

Community
  • 1
  • 1
Bentley4
  • 10,678
  • 25
  • 83
  • 134

1 Answers1

1
ack-grep -l Peter | xargs ack-grep -l James | xargs ack-grep 'Peter|James'
John Kugelman
  • 349,597
  • 67
  • 533
  • 578
  • The top answer only shows occurences of `James` while the one at the bottom does not output anything at all. – Bentley4 Feb 23 '13 at 18:14