(How) Can I find files where there are occurrences of 2 words in that same file, say Peter
and James
? Is it possible with ack-grep
?
You can just grep twice:
grep -l Peter * | xargs grep -l James
The same works with ack
:
ack -l Peter * | xargs ack -l James
You can replace the *
with whatever other file list you might care about, or use find
to generate a list for you.