问题
(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
?
回答1:
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.
来源:https://stackoverflow.com/questions/15042580/find-files-where-2-given-words-occur-in