ack is the replacement I wrote for grep, aimed at large trees of heterogeneous code.
Using it will change your life, but why? Here's my top 10 list:
- Searches recursively through directories by default, while ignoring
.svn, CVS and other VCS directories.
- Which would you rather type?
$ grep pattern $(find . | 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~
- binary files
- Lets you specify file types to search, as in --perl or --nohtml.
- Which would you rather type?
$ grep pattern $(find . -name '*.pl' -or -name '*.pm' -or -name '*.pod' | grep -v .svn)
$ ack --perl pattern
Note that ack's --perl also checks the shebang lines of
files without suffixes, which the find command will not.
- File-filtering capabilities usable without searching with ack -f. Want a list of all Perl files in a tree? Use ack -f --perl.
- Color highlighting of search results.
- Uses real Perl regular expressions, not a GNU subset.
- Allows you to specify output using Perl's special variables
- Example: ack '(Mr|Mr?s). (Smith|Jones)' --output='$&'
- Many command-line switches are the same as in GNU grep:
-w does word-only searching
-c shows counts per file of matches
-l gives the filename instead of matching lines
etc.
- ack is pure Perl, so consistent across all platforms.
- Command name is 25% shorter. :-) Heck, it's 50% shorter compared to grep -r.
To install it, install the Perl module App::Ack. Your coding life will never be the same.
Visit the home page at http://petdance.com/ack
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|