App::Ack::Intro - An introduction to ack
Ack is a powerful alternative to grep for programmers. It's made to make a programmer's life easier by optimizing common tasks that programmers face every day.
Ack can easily be restricted so it only matches whole words, not portions of words, by adding either -w
or --word-regexp
. For example,
ack --w skip
will match lines that have the word "skip" by itself, but will not match strings like "skipping" or "skipped".
This is identical to:
ack '\bskip\b'
Ack automatically ignores directories having to do with version control systems, but sometimes you just want to exclude a directory for the duration of one command. For example, to keep ack from searching your 'test' directory, use --ignore-dir=test/
.
Ack doesn't have to be installed system-wide for you to use it.
Copyright 2005-2010 Andy Lester.
This program is free software; you can redistribute it and/or modify it under the terms of either:
the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or
the "Artistic License" which comes with Perl 5.
Off the topic of my head:
1. -h (--no-filename) , -l (only filenames) etc. Also exist in GNU grep, but they are still useful.
2. I have this in my .ackrc:
Add Website Meta Language files to .html. --type-add=html=.wml
# Add CMake files --type-set=cmake=.txt,.cmake
[/quote]
Other stuff can be added.
3. -i for case insensitive searches.
5. ack -f for displaying a list of files in the current directory that are not temporary/version-control-related/etc.
6. -a for showing all files.
7. Sometimes I use --nofollow (especially as root).
8. --print0 is useful with xargs (though I haven't used it a lot yet).