- It's blazingly fast because it only searches the stuff you want searched.
- Searches recursively through directories by default, while ignoring .svn, CVS and other VCS directories. Which would you rather type?
- $ grep pattern $(find . -type f | grep -v '\.svn')
- $ ack pattern
- ack ignores most of the crap you don't want to search
- VCS directories
- blib, the Perl build directory
- backup files like foo~ and #foo#
- binary files, core dumps, etc
- Ignoring .svn directories means that ack is faster than grep for searching through trees.
- Lets you specify file types to search, as in --perl or --nohtml. Which would you rather type? (Note that ack's --perl also checks the shebang lines of files without suffixes, which the find command will not.)
- $ grep pattern $(find . -name '*.pl' -or -name '*.pm' -or -name '*.pod' | grep -v .svn)
- $ ack --perl pattern
- File-filtering capabilities usable without searching with ack -f. This lets you create lists of files of a given type.
- Color highlighting of search results.
Welcome to End Point's Blog
Ongoing observations by End Point people.
Thursday, March 19, 2009
Ack, grep for Developers
A relatively new tool in my kit that I've come to use very frequently over the last 6 months or so is Ack. Notwithstanding that it is written in my preferred development language, and is maintained by a developer active in the Perl community working on some important projects, like TAP, it really does just save typing while producing Real Purdy output. I won't go so far as to say it completely replaces grep, at least not without a learning curve and especially for people doing more "adminesque" tasks, but as a plain old developer I find its default set of configuration and output settings incredibly efficient for my common tasks. I'd go into the benefits myself, but I think the "Top 10 reasons to use ack instead of grep." from the ack site pretty much covers it. To highlight a couple here,
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment