_   /|
\'o.O'
=(___)=
   U    ack!
Google Groups
Subscribe to ack announcements
Email:
Browse Archives at groups.google.com

Subscribe to ack dev/users
Email:
Browse Archives at groups.google.com

Subscribe to ack commits
Email:
Browse Archives at groups.google.com

Latest version of ack: 1.86, July 9th, 2008

Read the Changelog

ack is a tool like grep, aimed at programmers with large trees of heterogeneous source code.

ack is written purely in Perl, and takes advantage of the power of Perl's regular expressions. It can be installed any number of ways:

Ack in Project for Textmate users

Users of TextMate, the programmer's editor for the Mac, can use the Ack in Project plugin by Trevor Squires:

TextMate users know just how slow its “Find in Project” can be with large source trees. That’s why you need "ack-in-project" – a TextMate bundle that uses the super-speedy ‘ack’ tool to search your code FAST. It gives you beautiful, clickable results just as fast as "ack" can find them. Check it out at: http://github.com/protocool/ack-tmbundle/tree/master

Testimonials

"Whoa, this is *so* much better than grep it's not even funny." -- Jacob Kaplan-Moss, creator of Django.

"Thanks for creating ack and sharing it with the world. It makes my days just a little more pleasant. I'm glad to have it in my toolbox. That installation is as simple as downloading the standalone version and chmodding is a nice touch." -- Alan De Smet

"I came across ack today, and now grep is sleeping outside. It's very much like grep, except it assumes all the little things that you always wanted grep to remember, but that it never did. It actually left the light on for you, and put the toilet seat down." -- Samuel Huckins

"ack is the best tool I have added to my toolbox in the past year, hands down." -- Bill Mill on reddit

"I use it all the time and I can't imagine how I managed with only grep." -- Thomas Thurman

"This has been replacing a Rube Goldberg mess of find/grep/xargs that I've been using to search source files in a fairly large codebase." -- G. Wade Johnson

"You had me at --thpppt." -- John Gruber, Daring Fireball

"Grepping of SVN repositories was driving me crazy until I found ack. It fixes all of my grep annoyances and adds features I didn't even know I wanted." -- Paul Prescod

"I added ack standalone to our internal devtools project at work. People are all over it." -- Jason Gessner

"I just wanted to send you my praise for this wonderful little application. It's in my toolbox now and after one day of use has proven itself invaluable." -- Benjamin W. Smith

"ack has replaced grep for me for 90% of what I used it for. Obsoleted most of my 'grep is crippled' wrapper scripts, too." -- Randall Hansen

"ack's powerful search facilities are an invaluable tool for searching large repositories like Parrot. The ability to control the search domain by filetype--and to do so independent of platform--has made one-liners out of many complex queries previously done with custom scripts. Parrot developers are hooked on ack." -- Jerry Gay

"That thing is awesome. People see me using it and ask what the heck it is." -- Andrew Moore

Top 10 reasons to use ack instead of grep.

  1. It's blazingly fast because it only searches the stuff you want searched.
  2. ack is pure Perl, so it runs on Windows just fine.
  3. The standalone version uses no non-standard modules, so you can put it in your ~/bin without fear.
  4. Searches recursively through directories by default, while ignoring .svn, CVS and other VCS directories.
  5. ack ignores most of the crap you don't want to search
  6. Ignoring .svn directories means that ack is faster than grep for searching through trees.
  7. Lets you specify file types to search, as in --perl or --nohtml. Note that ack's --perl also checks the shebang lines of files without suffixes, which the find command will not.
  8. File-filtering capabilities usable without searching with ack -f. This lets you create lists of files of a given type.
    $ ack -f --perl > all-perl-files
  9. Color highlighting of search results.
  10. Uses real Perl regular expressions, not a GNU subset.
  11. Allows you to specify output using Perl's special variables
  12. 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.
  13. Command name is 25% fewer characters to type! Save days of free-time! Heck, it's 50% shorter compared to grep -r.

Ack's command flags

$ ack --help
Usage: ack [OPTION]... PATTERN [FILES]

Search for PATTERN in each source file in the tree from cwd on down.
If [FILES] is specified, then only those files/directories are checked.
ack may also search STDIN, but only if no FILES are specified, or if
one of FILES is "-".

Default switches may be specified in ACK_OPTIONS environment variable or
an .ackrc file. If you want no dependency on the environment, turn it
off with --noenv.

Example: ack -i select

Searching:
  -i, --ignore-case     Ignore case distinctions in PATTERN
  --[no]smart-case      Ignore case distinctions in PATTERN,
                        only if PATTERN contains no upper case
                        Ignored if -i is specified
  -v, --invert-match    Invert match: select non-matching lines
  -w, --word-regexp     Force PATTERN to match only whole words
  -Q, --literal         Quote all metacharacters; PATTERN is literal

Search output:
  --line=NUM            Only print line(s) NUM of each file
  -l, --files-with-matches
                        Only print filenames containing matches
  -L, --files-without-match
                        Only print filenames with no match
  -o                    Show only the part of a line matching PATTERN
                        (turns off text highlighting)
  --passthru            Print all lines, whether matching or not
  --output=expr         Output the evaluation of expr for each line
                        (turns off text highlighting)
  --match PATTERN       Specify PATTERN explicitly.
  -m, --max-count=NUM   Stop searching in each file after NUM matches
  -1                    Stop searching after one match of any kind
  -H, --with-filename   Print the filename for each match
  -h, --no-filename     Suppress the prefixing filename on output
  -c, --count           Show number of lines matching per file

  -A NUM, --after-context=NUM
                        Print NUM lines of trailing context after matching
                        lines.
  -B NUM, --before-context=NUM
                        Print NUM lines of leading context before matching
                        lines.
  -C [NUM], --context[=NUM]
                        Print NUM lines (default 2) of output context.

  --print0              Print null byte as separator between filenames,
                        only works with -f, -g, -l, -L or -c.

File presentation:
  --pager=COMMAND       Pipes all ack output through COMMAND.
                        Ignored if output is redirected.
  --nopager             Do not send output through a pager.  Cancels any
                        setting in ~/.ackrc, ACK_PAGER or ACK_PAGER_COLOR.
  --[no]heading         Print a filename heading above each file's results.
                        (default: on when used interactively)
  --[no]break           Print a break between results from different files.
                        (default: on when used interactively)
  --group               Same as --heading --break
  --nogroup             Same as --noheading --nobreak
  --[no]color           Highlight the matching text (default: on unless
                        output is redirected, or on Windows)
  --[no]colour          Same as --[no]color
  --flush               Flush output immediately, even when ack is used
                        non-interactively (when output goes to a pipe or
                        file).

File finding:
  -f                    Only print the files found, without searching.
                        The PATTERN must not be specified.
  -g REGEX              Same as -f, but only print files matching REGEX.
  --sort-files          Sort the found files lexically.

File inclusion/exclusion:
  -a, --all-types       All file types searched;
                        Ignores CVS, .svn and other ignored directories
  -u, --unrestricted    All files and directories searched
  --[no]ignore-dir=name Add/Remove directory from the list of ignored dirs
  -n                    No descending into subdirectories
  -G REGEX              Only search files that match REGEX

  --perl                Include only Perl files.
  --type=perl           Include only Perl files.
  --noperl              Exclude Perl files.
  --type=noperl         Exclude Perl files.
                        See "ack --help type" for supported filetypes.

  --type-set TYPE=.EXTENSION[,.EXT2[,...]]
                        Files with the given EXTENSION(s) are recognized as
                        being of type TYPE. This replaces an existing
                        definition for type TYPE.
  --type-add TYPE=.EXTENSION[,.EXT2[,...]]
                        Files with the given EXTENSION(s) are recognized as
                        being of (the existing) type TYPE

  --[no]follow          Follow symlinks.  Default is off.

  Directories ignored by default:
    autom4te.cache, blib, _build, .bzr, .cdv, cover_db, CVS, _darcs, ~.dep,
    ~.dot, .git, .hg, ~.nib, .pc, ~.plst, RCS, SCCS, _sgbak and .svn

  Files not checked for type:
    /~$/           - Unix backup files
    /#.+#$/        - Emacs swap files
    /[._].*\.swp$/ - Vi(m) swap files
    /core\.\d+$/   - core dumps

Miscellaneous:
  --noenv               Ignore environment variables and ~/.ackrc
  --help                This help
  --man                 Man page
  --version             Display version & copyright
  --thpppt              Bill the Cat

This is version 1.86 of ack.

File types that ack understands

$ ack --help-types
Usage: ack [OPTION]... PATTERN [FILES]

The following is the list of filetypes supported by ack.  You can
specify a file type with the --type=TYPE format, or the --TYPE
format.  For example, both --type=perl and --perl work.

Note that some extensions may appear in multiple types.  For example,
.pod files are both Perl and Parrot.

    --[no]actionscript .as .mxml
    --[no]asm          .asm .s
    --[no]batch        .bat .cmd
    --[no]binary       Binary files, as defined by Perl's -B op (default: off)
    --[no]cc           .c .h .xs
    --[no]cfmx         .cfc .cfm .cfml
    --[no]cpp          .cpp .cc .cxx .m .hpp .hh .h .hxx
    --[no]csharp       .cs
    --[no]css          .css
    --[no]elisp        .el
    --[no]erlang       .erl
    --[no]fortran      .f .f77 .f90 .f95 .f03 .for .ftn .fpp
    --[no]haskell      .hs .lhs
    --[no]hh           .h
    --[no]html         .htm .html .shtml .xhtml
    --[no]java         .java .properties
    --[no]js           .js
    --[no]jsp          .jsp .jspx .jhtm .jhtml
    --[no]lisp         .lisp .lsp
    --[no]lua          .lua
    --[no]make         Makefiles
    --[no]mason        .mas .mhtml .mpl .mtxt
    --[no]objc         .m .h
    --[no]objcpp       .mm .h
    --[no]ocaml        .ml .mli
    --[no]parrot       .pir .pasm .pmc .ops .pod .pg .tg
    --[no]perl         .pl .pm .pod .t
    --[no]php          .php .phpt .php3 .php4 .php5
    --[no]plone        .pt .cpt .metadata .cpy .py
    --[no]python       .py
    --[no]ruby         .rb .rhtml .rjs .rxml .erb
    --[no]scheme       .scm
    --[no]shell        .sh .bash .csh .tcsh .ksh .zsh
    --[no]skipped      Files, but not directories, normally skipped by ack (default: off)
    --[no]smalltalk    .st
    --[no]sql          .sql .ctl
    --[no]tcl          .tcl .itcl .itk
    --[no]tex          .tex .cls .sty
    --[no]text         Text files, as defined by Perl's -T op (default: off)
    --[no]tt           .tt .tt2 .ttml
    --[no]vb           .bas .cls .frm .ctl .vb .resx
    --[no]vim          .vim
    --[no]xml          .xml .dtd .xslt .ent
    --[no]yaml         .yaml .yml