How to grep files in git repo?
You might consider a non-git solution in this case.
find
itself has the ability to do what you want in a more efficient manner than piping its results into grep
:
find . -name 'middleware*'
You will need to quote the pattern so that the *
isn't expanded by the shell before being passed to find
.
There is a powerful program called ack
that is, well, better than grep, and one of my favorite uses for ack
is exactly what you've mentioned -- finding files that match a pattern within a tree. ack
uses perl regexps, not shell fileglobs, though.
ack -g middleware
If you want to search within those files, ack
lets you do that more easily than writing a shell loop over the results of find
that grep
s within each file. Compare the two and see which one you prefer:
for f in $(find . -name 'middleware*')do grep 'pattern in file' $fdone
versus
ack -G 'middleware' 'pattern in file'
I highly recommend ack
as something to add to your toolkit.