This is the Frequently Asked Questions list for ack. You can also see the manual in the Perl module App::Ack::Docs::Manual, or running ack --man.
Many people find ack to be better than grep as an everyday tool 99% of the time, but don't throw grep away, because there are times you'll still need it. For example, you might be looking through huge log files and not using regular expressions. In that case, grep will probably perform better.
First, take a look and see if ack is even looking at the file. ack is intelligent in what files it will search and which ones it won't, but sometimes that can be surprising.
Use the -f switch, with no regex, to see a list of files that ack will search for you. If your file doesn't show up in the list of files that ack -f shows, then ack never looks in it.
-f
ack -f
No, ack will always be read-only. Perl has a perfectly good way to do search & replace in files, using the -i, -p and -n switches.
-i
-p
-n
You can certainly use ack to select your files to update. For example, to change all "foo" to "bar" in all PHP files, you can do this from the Unix shell:
$ perl -i -p -e's/foo/bar/g' $(ack -f --php)
Yes! Please see "Defining your own types" in the ack manual.
We might, depending on how widely-used the file format is.
Submit an issue at in the GitHub issue queue at https://github.com/beyondgrep/ack3/issues. Explain what the file format is, where we can find out more about it, and what you have been using in your .ackrc to support it.
Please do not bother creating a pull request. The code for filetypes is trivial compared to the rest of the process we go through.
The name of the program is "ack". Some packagers have called it "ack-grep" when creating packages because there's already a package out there called "ack" that has nothing to do with this ack.
I suggest you make a symlink named ack that points to ack-grep because one of the crucial benefits of ack is having a name that's so short and simple to type.
To do that, run this with sudo or as root:
ln -s /usr/bin/ack-grep /usr/bin/ack
Alternatively, you could use a shell alias:
# bash/zsh alias ack=ack-grep # csh alias ack ack-grep
Nothing. I wanted a name that was easy to type and that you could pronounce as a single syllable.
No, ack does not support regexes that match multiple lines. Doing so would require reading in the entire file at a time.
If you want to see lines near your match, use the --A, --B and --C switches for displaying context.
--A
--B
--C
+foo
ack treats command line options beginning with + or - as options; if you would like to search for these, you may prefix your search term with -- or use the --match option. (However, don't forget that + is a regular expression metacharacter!)
+
-
--
--match
"ack '.{40000,}'"
The Perl language limits the repetition quantifier to 32K. You can search for .{32767} but not .{32768}.
.{32767}
.{32768}
We try to remain as close to grep's behavior as possible, so when in doubt, see what grep does! If there's a mismatch in functionality there, please submit an issue to GitHub, and/or bring it up on the ack-users mailing list.
To install App::Ack, copy and paste the appropriate command in to your terminal.
cpanm
cpanm App::Ack
CPAN shell
perl -MCPAN -e shell install App::Ack
For more information on module installation, please visit the detailed CPAN module installation guide.