4 ms·
I'm pretty accustomed to using find | xargs grep. This lets me completely tailor the file I search using find's filters (e.g., only search files with a .py ext
by ams6110 13y ago
I'm pretty accustomed to using find | xargs grep.
This lets me completely tailor the file I search using find's filters (e.g., only search files with a .py extension, and skip .svn/ directory). E.g. assuming I'm in my project's root directory:
find . -name .svn -prune -o -name '*.py' -print | xargs grep -Hi 'string or RE I am looking for'
- pyre 13y agoOr you can do: ack --python PATTERN [DIRECTORY]
- michaelmior 13y agoI used to do the same, but this accomplishes the same thing and is much more concise ag -i -G '\.py$' 'string or RE I am looking for'
- troels 13y agoI'm pretty happy with `find|xargs grep` myself. Of course, I have an alias that hides the arcane incantation away under a single `frep`, but underneath it uses those tried and tested unix tools. An alias is usually simpler to carry with me to new systems as well.
- ams6110 13y agoMy alias is my .bash_history :). I grant that these other tools are great, but I like using the standard utilities because, among other things, once you learn 'find' and 'xargs' you can piece together all kinds of other commands and you don't have to remember a tool-specific syntax (at least for the 'find' and 'xargs' parts).