Suppose I do ag -l foo
. That gets me a list of files.
How can I use ag a second time to search within just those files?
Assuming you're in the bash shell, you do this:
ag whatever $(ag -l foo)
So to find all the files that match both cat and dog:
ag cat $(ag -l dog)
You could also use xargs
:
ag -l dog | xargs ag cat
If you used ack
, another greplike tool, you could use the -x
option to read the list of input files from stdin:
ack -l dog | ack -x cat