Skip to content

Latest commit

 

History

History
119 lines (67 loc) · 2.67 KB

Intro.pod

File metadata and controls

119 lines (67 loc) · 2.67 KB

NAME

App::Ack::Intro - An introduction to ack

WHAT ACK CAN DO

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.

THE PHILOSOPHY OF ACK

SPECIFY YOUR SEARCHES

Use Perl regular expressions

Search without regard to case with -i

Do smart case searching with --smartcase

Match only whole words with -w

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'

CONTROL WHERE YOU SEARCH

Automatically search entire directory trees

Automatically ignore VCS directories

Limit by language with --perl, --html, --sql etc

Exclude languages with --noperl, --nohtml, --nosql etc

Ignore directories from search --ignore-dir

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/.

CONTROL SEARCH RESULTS

Show only the match with -o

Show context lines around the match with -A, -B and -C

CUSTOMIZE ACK

~/.ackrc

ACK_OPTIONS

TAKE ACK WITH YOU

Put ack in your ~/bin

Ack doesn't have to be installed system-wide for you to use it.

COPYRIGHT & LICENSE

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