Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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'


I 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'


Or you can do:

  ack --python PATTERN [DIRECTORY]


I'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.


My 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).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: