ACK(1)
πΈ ACK(1) πΈ
okay bestie, this is the ACK manual page π It's section 1 (the user commands bit), from the User Contributed Perl Documentation crowd π§
πΈ NAME πΈ
ack - grep-like text finder β¨ ack is a grep-like text finder, and it's literally iconic π
π¦ SYNOPSIS π¦
ack [options] PATTERN [FILE...]
ack -f [options] [DIRECTORY...]
π DESCRIPTION π
okay so ack is made for programmers, and it's giving alternative-to-grep energy π₯
ack searches the FILEs or DIRECTORYs you name for lines that match the PATTERN π¦ By default it prints the matching lines. If you don't give it a FILE or DIRECTORY, ack searches the current directory π
PATTERN is a Perl regular expression π Regexes show up in plenty of other languages too, but for the exact details of how they behave, check out perlreref (<https://perldoc.perl.org/perlreref.html>). If regexes are new to you and you're curious, perlretut (<https://perldoc.perl.org/perlretut.html>) is a great place to start π§ And if you don't want ack to use regexes at all, look at the -Q/--literal option π
Ack can also list the files it would search without actually searching them π That lets you use ack's file-type filtering skills without the actual search β¨
π§ FILE SELECTION π§
If you don't specify files, either on the command line or piped in with the -x option, ack dives into subdirectories and picks files to search πΈ
ack is super picky (in a good way) about what it searches π
It knows about certain file types, using the file extension and, in some cases, the contents of the file. You can make these selections with the --type option π
With no file selection, ack searches regular files that aren't explicitly excluded by --ignore-dir and --ignore-file options, whether they're in ackrc files or on the command line π¦
The default options ignore certain files and directories, including:
- Backup files: files matching
#*#or ending with~. - Coredumps: files matching
core.\d+. - Version control directories like
.svnand.git.
Run ack with the --dump option to see what settings are set π
β οΈ Heads up: ack always searches the files you give it on the command line, no matter what type they are. So if you tell ack to search in a coredump, it will search in a coredump π
π DIRECTORY SELECTION π
ack goes down through the directory tree of the starting directories you specify π³ If you don't specify any, it uses the current working directory π It does ignore the shadow directories many version control systems use, plus the build directories used by the Perl MakeMaker system π You can add or remove a directory from this list with the --[no]ignore-dir option. You can repeat the option to add or remove multiple directories from the ignore list β¨
For a full list of directories that don't get searched, run ack --dump π§
π MATCHING IN A RANGE OF LINES π
The --range-start and --range-end options let you pick ranges of lines to search inside each file π¦
Say you have a file called testfile:
# This function calls print on "foo".
sub foo {
print 'foo';
}
my $print = 1;
sub bar {
print 'bar';
}
my $task = 'print';
Running ack print gives us five matches:
$ ack print testfile
# This function calls print on "foo".
print 'foo';
my $print = 1;
print 'bar';
my $task = 'print';
But what if we only want to search for "print" inside the subroutines? π We can set ranges of lines for ack to search π
A range starts at any line matching ^sub \w+ and stops at any line matching ^} β¨
$ ack --range-start='^sub \w+' --range-end='^}' print testfile
print 'foo';
print 'bar';
Notice that ack searched two ranges of lines π The listing below shows which lines were inside a range and which were outside it:
Out # This function calls print on "foo".
In sub foo {
In print 'foo';
In }
Out my $print = 1;
In sub bar {
In print 'bar';
In }
Out my $task = 'print';
You don't have to set both --range-start and --range-end πΈ If --range-start is left out, the range runs from the first line of the file until the first line matching --range-end. And if --range-end is left out, the range runs from the first line matching --range-start to the end of the file π¦
For example, if you wanted to search all HTML files up until the first <body>, you could do:
ack foo --html --range-end='<body>'
Or, to search after Perl's __DATA__ or __END__ markers, you would do:
ack pattern --perl --range-start='^__(END|DATA)__'
It's also possible for a range to start and stop on the same line π€― For example:
--range-start='<title>' --range-end='</title>'
would match this line as both the start and end of the range, making a one-line range:
<title>Page title</title>
Note that the patterns in --range-start and --range-end aren't affected by options like -i, -w and -Q that change how the main pattern gets matched π§
Again, ranges only affect where matches are looked for π Everything else in ack works the same way. Using the -c option with a range gives you a count of all the matches inside those ranges π’ The -l option shows the files that have a match within a range, and the -L option shows files that don't have a match within a range π
The -v option for negating a match works inside the range, too π To see lines that don't match "google" inside the <head> section of your HTML files, you could do:
ack google -v --html --range-start='<head' --range-end='</head>'
Specifying a range doesn't change how matches are displayed π The context for a match stays the same. Using the context options works the same way too, and they'll show context lines for matches even if those context lines fall outside the range β¨ Similarly, --passthru shows all lines in the file, but only shows matches for lines inside the range π
π OPTIONS π
--ackrcβ Loads an ackrc file after all the others. Peep "ACKRC LOCATION SEMANTICS" for the deets π--and=PATTERNβ Says that a given PATTERN MUST ALSO be found on the line for a match to happen. You can repeat this option πΆπ± If you want to find all the lines with both "dogs" or "cats", use:
ack dogs --and cats
Note that the options that affect "dogs" also affect "cats" π So if you have:
ack -i -w dogs --and cats
then the search for both "dogs" and "cats" will be case-insensitive and word-limited π
--and cannot be used with --or π«
-A NUM,--after-context=NUMβ Prints NUM lines of trailing context after matching lines πΈ-B NUM,--before-context=NUMβ Prints NUM lines of leading context before matching lines π¦--[no]breakβ Prints a break between results from different files. It's on by default when you're using ack interactively π-C [NUM],--context[=NUM]β Prints NUM lines (default 2) of context around matching lines π§ You can specify zero lines of context to override another context set in an ackrc π ββοΈ-c,--countβ Suppresses the normal output and prints a count of matching lines for each input file π’ If-lis in effect, it only shows the number of lines for each file that has matching lines. Without-l, some line counts may be zeroes π If combined with-h(--no-filename), ack outputs only one total count β¨-h,--no-filenameβ Hide the filename prefixes on output when you're searching more than one file π--[no]headingβ Prints a filename heading above each file's results π This is the default when you're using ack interactively β¨--helpβ Shows a short help statement π--help-typesβ Prints all the known types π§--help-colorsβ Shows a chart of various color combinations π--help-rgb-colorsβ Like--help-colors, but with more precise RGB colors π-i,--ignore-caseβ Ignores case distinctions in PATTERN. Overrides--smart-caseand-I. π«Ά-I,--no-ignore-caseβ Turns on case distinctions in PATTERN. Overrides--smart-caseand-i. π--ignore-ack-defaultsβ Tells ack to totally ignore the default definitions that come with ack. This is super useful alongside--create-ackrcif you really, truly want to customize ack π§--[no]ignore-dir=DIRNAME,--[no]ignore-directory=DIRNAMEβ Ignores a directory, just likeCVS,.svn, and friends get ignored π You can use it multiple times to ignore multiple directories. For example, mason users may wish to include--ignore-dir=data. The--noignore-diroption lets you search directories that would normally be ignored (perhaps to research the contents of.svn/propsdirectories) π
The DIRNAME must always be a simple directory name. Nested directories likefoo/barare NOT supported. You would need to specify--ignore-dir=fooand then no files from any foo directory are taken into account by ack unless given explicitly on the command line. π
--ignore-file=FILTER:ARGSβ Ignores files matchingFILTER:ARGSπ The filters are set up identically to file type filters, the same way you'd see them in "Defining your own types" π-k,--known-typesβ Limits the selected files to only the types ack already knows about π§-l,--files-with-matchesβ Only prints the filenames of matching files, instead of the matching text π-L,--files-without-matchesβ Only prints the filenames of files that do NOT match π«--match PATTERNβ Lets you specify the PATTERN explicitly π― This is handy if you don't want the regex to be your first argument, like when you're running multiple searches over the same set of files π
# search for foo and bar in given files
ack file1 t/file* --match foo
ack file1 t/file* --match bar
-m=NUM,--max-count=NUMβ Prints onlyNUMmatches out of each file βοΈ If you want ack to stop after printing the first match of any kind, use the-1options π--manβ Prints this manual page π-n,--no-recurseβ No descending into subdirectories π--not=PATTERNβ Specifies a PATTERN that must NOT be true on a given line for a match to happen π« This option can be repeated π Want all the lines with "dogs" but not if "cats" or "fish" show up on the line? Use:
ack dogs --not cats --not fish
Heads up: the options that affect "dogs" also affect "cats" and "fish", so if you have:
ack -i -w dogs --not cats
then the search for both "dogs" and "cats" will be case-insensitive and word-limited π
-oβ Shows only the part of each line matching PATTERN (turns off text highlighting) βοΈ This is exactly the same as--output=$&.--or=PATTERNβ Specifies a PATTERN that MAY be found on a given line for a match to happen π€· This option can be repeated π Want all the lines with "dogs" or "cats"? Use:
ack dogs --or cats
Heads up: the options that affect "dogs" also affect "cats", so if you have:
ack -i -w dogs --or cats
then the search for both "dogs" and "cats" will be case-insensitive and word-limited π
"--or" cannot be used with "--and". π
--output=exprβ Outputs the evaluation ofexprfor each line πͺ (turns off text highlighting). If PATTERN matches more than once, a line is output for each non-overlapping match π₯
expr can contain the strings "\n", "\r", and "\t", which get expanded to their matching characters: line feed, carriage return, and tab, respectively β¨
expr can also contain the following Perl special variables π
$1through$9β The subpattern from the matching set of capturing parentheses. If your pattern is"(.+) and (.+)"and the string is"this and that'", then$1is"this"and$2is"that"π§©$_β The contents of the line in the file π$.β The number of the line in the file π’$&,$`, and$'β$&is the string matched by the pattern,$`is what precedes the match, and$'is what follows it. If the pattern isgra(ph|nd)and the string is"lexicographic", then$&is"graph",$`is"lexico", and$'is"ic"π«$+β The match made by the last parentheses that matched in the pattern π― For example, if your pattern is"Version: (.+)|Revision: (.+)", then$+will contain whichever set of parentheses matched.$fβ$fis available, in--outputonly, to insert the filename π This is a stand-in for the discovered$filenameusage in oldack2 --output, which is disallowed withack3for improved security π
Use of$&,$`, and$'in your output will slow down the pattern matching π
The intended usage of $f is to provide the grep or compile-error syntax needed for editor/IDE go-to-line integration, e.g. --output=$f:$.:$_ or --output=$f\t$.\t$& π§βπ»
--pager=program,--nopagerβ--pagerdirects ack's output throughprogramπΊ This can also be specified via theACK_PAGERandACK_PAGER_COLORenvironment variables πΈ Using--pagerdoes not suppress grouping and coloring like piping output on the command line does π¨--nopagercancels any setting in~/.ackrc,ACK_PAGER, orACK_PAGER_COLORπ No output will be sent through a pager.--passthruβ Prints all lines, whether or not they match the expression π Highlighting still works, though, so it can be used to highlight matches while still seeing the entire file π Like this:
# Watch a log file, and highlight a certain IP address.
$ tail -f ~/access.log | ack --passthru 123.45.67.89
--print0β Only works in conjunction with-f,-g,-l, or-c, options that only list filenames π The filenames are output separated with a null byte instead of the usual newline π This is helpful when dealing with filenames that contain whitespace, e.g.:
# Remove all files of type HTML.
ack -f --html --print0 | xargs -0 rm -f
-p[N],--proximate[=N]β Groups together match lines that are withinNlines of each other π«§ This is useful for visually picking out matches that appear close to other matches π For example, if you got these results without the--proximateoption:
15: First match
18: Second match
19: Third match
37: Fourth match
They'd look like this with --proximate=1:
15: First match
18: Second match
19: Third match
37: Fourth match
and like this with --proximate=3:
15: First match
18: Second match
19: Third match
37: Fourth match
If N is omitted, N is set to 1 π§
-Pβ Negates the effect of the--proximateoption π It's a shortcut for--proximate=0.-Q,--literalβ Quotes all metacharacters in PATTERN, so it's treated as a literal π§·-r,-R,--recurseβ Recurses into subdirectories π This is the default and is only here for compatibility with grep π€ You can also use it to turn--no-recurseoff π--range-start=PATTERN,--range-end=PATTERNβ Specifies patterns that mark the start and end of a range π’ See "MATCHING IN A RANGE OF LINES" for details π-sβ Suppresses error messages about nonexistent or unreadable files π€« This one is taken fromfgrep.-S,--[no]smart-case,--no-smart-caseβ Ignores case in the search strings if PATTERN contains no uppercase characters π§ This is similar to "smartcase" in the vim text editor π Overrides-iand-I.-Sis a synonym for--smart-case.-ialways overrides this option π--sort-filesβ Sorts the found files lexicographically π€ Use this if you want your file listings to be deterministic between runs of ack π―--show-typesβ Outputs the filetypes that ack associates with each file π·οΈ Works with-fand-goptions.-t TYPE,--type=TYPE,--TYPEβ Specifies the types of files to include in the search π―TYPEis a filetype, likeperlorxml.--type=perlcan also be specified as--perl, although this is deprecated β οΈ Type inclusions can be repeated and are ORed together π Seeack --help-typesfor a list of valid types π-T TYPE,--type=noTYPE,--noTYPEβ Specifies the type of files to exclude from the search π«--type=noperlcan be done as--noperl, although this is deprecated. If a file is of both type "foo" and "bar", specifying both--type=fooand--type=nobarwill exclude the file, because an exclusion takes precedence over an inclusion π--type-add TYPE:FILTER:ARGSβ Files with the givenARGSapplied to the givenFILTERare recognized as being of (the existing) typeTYPEβ See also "Defining your own types".--type-set TYPE:FILTER:ARGSβ Files with the givenARGSapplied to the givenFILTERare recognized as being of typeTYPEπ This replaces an existing definition for typeTYPE. See also "Defining your own types".--type-del TYPEβ The filters associated withTYPEare removed from Ack, and are no longer considered for searches ποΈ--[no]underlineβ Turns on underlining of matches, where "underlining" is printing a line of carets under the match πΊ Check it out:
$ ack -u foo
peanuts.txt
17: Come kick the football you fool
^^^ ^^^
623: Price per square foot
^^^
This is useful if you're dumping the results of an ack run into a text file or printer that doesn't support ANSI color codes π¨οΈ The setting of underline does not affect highlighting of matches π
-v,--invert-matchβ Invert match: selects non-matching lines π--versionβ Displays version and copyright information π-w,--word-regexpβ Forces PATTERN to match only whole words π―-xβ An abbreviation for--files-from=-π«Ά The list of files to search is read from standard input, with one line per file π₯
Heads up π
the list of files isn't filtered in any way with this one. If you toss --type=html in alongside -x, the --type just gets ignored, bestie π
-1β Stops right after the first match of any kind shows up β¨ This is NOT the same as--max-count=1or-m1, which only show one match per file. Also,-1plays nice with-fand-g, which-mdoesn't. Main character energy.--thppptβ Shows off the all-important Bill The Cat logo π± The exact spelling of--thppppptdoesn't really matter, because it gets checked against a regular expression, not an exact match π--barβ Goes and checks with the admiral for traps π§--cathyβ A whole chocolate chant: "Chocolate, Chocolate, Chocolate!" π«π
β¨ THE .ackrc FILE β¨
The .ackrc file is basically a little stash of command-line options that get tucked in front of your command line before ack runs π You can put several options across several lines, and any line starting with a # gets ignored. It might look something like this:
# Always sort the files
--sort-files
# Always color, even if piping to another program
--color
# Use "less -r" as my pager
--pager=less -r
Arguments with spaces in them don't need quotes, since the shell doesn't interpret them. Each line in the .ackrc file is interpreted as one element of @ARGV. Cute and simple π«Ά
ack checks several locations for .ackrc files. The whole searching process is detailed in "ACKRC LOCATION SEMANTICS," so go read that if you're curious π Also, these files get skipped entirely if --noenv is on the command line π
β¨ Defining your own types β¨
ack lets you make your own types on top of the predefined ones π¦ The move is to put these command-line options in an .ackrc, so you never have to retype them. The examples below put options on one command line so you can copy and paste them easily.
File types can be specified with --type=xxx, or with the type itself as an option. So if you create a filetype of "cobol," you can write --type=cobol or just --cobol. File types must be at least two characters long, which is why the C language is --cc and the R language is --rr π
ack --perl foo searches for foo in all perl files. ack --help-types tells you perl files are files ending in .pl, .pm, .pod or .t. Want .xs files included too? ack --type-add perl:ext:xs --perl foo does that for you. --type-add appends extra extensions to an existing type π
Need a brand new type, or want to completely redo an existing one? Use --type-set. ack --type-set eiffel:ext:e,eiffel defines the type eiffel to include files with the extensions .e or .eiffel. To search every eiffel file for the word Bertrand, use ack --type-set eiffel:ext:e,eiffel --eiffel Bertrand. As usual, you can also write --type=eiffel instead of --eiffel. Negation works too, so --noeiffel excludes all eiffel files from a search. Redefining works as well: ack --type-set cc:ext:c,h means .xs files no longer belong to the type cc π₯
When defining your own types in the .ackrc file, you have to use one of these:
--type-set=eiffel:ext:e,eiffel
or, writing it on separate lines:
--type-set
eiffel:ext:e,eiffel
π« Big no no: the following does NOT work in the .ackrc file:
--type-set eiffel:ext:e,eiffel
To see all the currently defined types, use --help-types, like this: ack --type-set backup:ext:bak --type-add perl:ext:perl --help-types
ack --type-set backup:ext:bak --type-add perl:ext:perl --help-types
In addition to filtering by extension, ack offers extra filter types πΈ The generic syntax is --type-set TYPE:FILTER:ARGS, and what ARGS looks like depends on the value of FILTER.
is:FILENAME
The is filter matches the target filename exactly. It takes exactly one argument, which is the name of the file to match.
Example:
--type-set make:is:Makefile
ext:EXTENSION[,EXTENSION2[,...]]
The ext filter matches the extension of the target file against a list of extensions. You don't need a leading dot on the extensions π
Example:
--type-set perl:ext:pl,pm,t
match:PATTERN
The match filter checks the target filename against a regular expression. The regex is made case-insensitive for the search π
Example:
--type-set make:match:/(gnu)?makefile/
firstlinematch:PATTERN
firstlinematch checks the first line of the target file against a regular expression. Like match, the regex is made case insensitive.
Example:
--type-add perl:firstlinematch:/perl/
β¨ ACK COLORS β¨
ack lets you customize the colors it uses when showing matches on screen π It uses the colors from Perl's Term::ANSIColor module, which provides the values listed below. Case doesn't matter when using these values.
There are four different colors ack uses:
- filename
- Option:
--color-filename - Env. variable:
ACK_COLOR_FILENAME - Default:
bold green
- Option:
- match
- Option:
--color-match - Env. variable:
ACK_COLOR_MATCH - Default:
black on_yellow
- Option:
- line no.
- Option:
--color-lineno - Env. variable:
ACK_COLOR_LINENO - Default:
bold yellow
- Option:
- column no.
- Option:
--color-colno - Env. variable:
ACK_COLOR_COLNO - Default:
bold yellow
- Option:
The column number one only shows up if column numbers are displayed because of the --column option π¦
You can set colors with a command-line option, like ack --color-filename='red on_white', or with an environment variable, like ACK_COLOR_FILENAME='red on_white'. You can also put color options in your ACKRC file (see "THE .ackrc FILE") π
ack understands these foreground colors:
black red green yellow blue magenta cyan white
To make a background color, prepend on_ to one of the foreground colors:
on_black on_red on_green on_yellow on_blue on_magenta on_cyan on_white
Each foreground color can be modified with these attributes, which may or may not be supported by your terminal:
bold faint italic underline blink reverse concealed
You can stack any combination of modifiers onto a foreground color. If your terminal supports it, and you enjoy visual punishment, you can do something like:
ack --color-filename="blink italic underline bold red on_yellow"
For charts of the colors and what they look like, run ack --help-colors and ack --help-rgb-colors π
If the eight standard colors (in their bold, faint and unmodified states) aren't enough for you, you can also specify colors by their RGB values β¨ They're written as rgbXYZ, where X, Y, and Z are values between 0 and 5 giving the intensity of red, green and blue. So rgb500 is pure red, rgb505 is purple, and so on π
Background colors work with the on_ prefix on an RGB color, so on_rgb505 is a purple background π
The modifier attributes like blink, italic, underscore and so on may or may not work on the RGB colors π
For a chart of the 216 possible RGB colors, run ack --help-rgb-colors πΈ
β¨ ENVIRONMENT VARIABLES β¨
For commonly-used ack options, environment variables can make life way easier π
These variables get ignored if --noenv is on the command line.
ACKRCβ Points to the location of the user's.ackrcfile. If that file doesn't exist, ack looks in the default location.ACK_COLOR_COLNOβ The color for the column number in ack's output. By default the column number isn't shown, so you have to turn it on with the--columnoption. See the "ack Colors" section above.ACK_COLOR_FILENAMEβ The color for the filename in ack's output. See the "ack Colors" section above.ACK_COLOR_LINENOβ The color for the line number in ack's output. See the "ack Colors" section above.ACK_COLOR_MATCHβ The color for the matched text in ack's output. See the "ack Colors" section above.ACK_PAGERβ Specifies a pager program, like "more," "less" or "most," that ack sends its output to. UsingACK_PAGERdoesn't suppress grouping and coloring the way piping on the command line does, except that on Windows ack assumesACK_PAGERdoesn't support color.ACK_PAGER_COLORoverridesACK_PAGERif both are specified.ACK_PAGER_COLORβ Specifies a pager program that understands ANSI color sequences. UsingACK_PAGER_COLORdoesn't suppress grouping and coloring the way piping on the command line does. If you're not on Windows, you never need to useACK_PAGER_COLOR. π«Ά
β¨ ACK & OTHER TOOLS β¨
Simple vim integration
ack plays nicely with Vim π Set this in your .vimrc to use ack instead of grep:
set grepprg=ack\ -k
That example uses -k to search through only the files of the types ack knows about, but you can use other default flags too. Now you can search with ack and easily step through the results in Vim:
:grep Dumper perllib
Editor integration
Lots of users have hooked ack up to their favorite text editors π¦ For details and links, see https://beyondgrep.com/more-tools/.
Shell and Return Code
For greater compatibility with grep, ack in normal use returns a shell return code (exit code) of 0 only if something is found, and 1 if no match is found π
(Shell exit code 1 is $?=256 in perl with system or backticks.)
The grep code 2 for errors is not used π
If -f or -g are specified, then 0 is returned if at least one file is found. If no files are found, then 1 is returned.
β¨ DEBUGGING ACK PROBLEMS β¨
If ack gives you output you're not expecting, don't panic, just start with a few simple steps π
Try it with --noenv
Your environment variables and .ackrc may be doing things you're not expecting, or things you forgot you specified π Use --noenv to ignore your environment and .ackrc.
Use -f to see what files have been selected for searching
Ack's -f was originally added as a debugging tool π§ If ack isn't finding matches you think it should find, run ack -f to see what files have been selected. You can also add the --show-types option to show the type of each file selected.
Use --dump
This lists the ackrc files that are loaded and the options loaded from them. You might be loading an .ackrc file you didn't even know you were loading π
β¨ ACKRC LOCATION SEMANTICS β¨
Okay bestie, ack can grab its settings from a bunch of different places πΊοΈπ«Ά. Each one that exists gets loaded in this exact order, and every later one overrides what the earlier ones set. Like, if I set --sort-files in my user ackrc but type --nosort-files on the command line, the command line wins. Main character energy π
- Defaults: ack starts with the defaults from
App::Ack::ConfigDefaults. You can skip those with--ignore-ack-defaultsπ - Global ackrc: next up is the global ackrc, which lives at
/etc/ackrcon Unix-like systems πΈ- Windows XP and earlier:
C:\Documents and Settings\All Users\Application Data\ackrc - Windows Vista/7:
C:\ProgramData\ackrc - The
--noenvoption stops every ackrc file from loading π
- Windows XP and earlier:
- User ackrc: then your own ackrc, at
$HOME/.ackrcon Unix-like systems π¦- Windows XP and earlier:
C:\Documents and Settings\$USER\Application Data\ackrc - Windows Vista/7:
C:\Users\$USER\AppData\Roaming\ackrc - Want a different user-level ackrc? Point the
$ACKRCenvironment variable at it β¨ - The
--noenvoption stops every ackrc file from loading π
- Windows XP and earlier:
- Project ackrc: then the project ackrc, which is the first file named
.ackrcor_ackrcthat ack finds. It checks the current directory first, then the parent directory, then the grandparent, and so on π§ You can skip this one with--noenv. --ackrc: the--ackrcoption on the command line can name an ackrc file that overrides all the others. It still gets consulted even when--noenvis there π- Command line: last but not least, options from the command line get loaded π
β¨ BUGS & ENHANCEMENTS β¨
Bugs happen to the best of us, so don't stress. ack lives on GitHub at https://github.com/beyondgrep/ack3 π
Report bugs or request features on the issues list at https://github.com/beyondgrep/ack3/issues. Please include the operating system you're on, the output of ack --version, and any customizations in your .ackrc π«Ά
Wanna suggest an enhancement? Submit an issue at https://github.com/beyondgrep/ack3/issues. Also read the DEVELOPERS.md file in the ack code repository π
Want to chat about your issues? Hop on the ack mailing list at https://groups.google.com/group/ack-users π¬
β¨ SUPPORT β¨
Support and info for ack live in all these spots π
- The ack homepage:
https://beyondgrep.com/ - Source repository:
https://github.com/beyondgrep/ack3 - The ack issues list at GitHub:
https://github.com/beyondgrep/ack3/issues - The ack announcements mailing list:
https://groups.google.com/group/ack-announcement - The ack users' mailing list:
https://groups.google.com/group/ack-users - The ack development mailing list:
https://groups.google.com/group/ack-users
β¨ COMMUNITY β¨
There are ack mailing lists and a Slack channel for ack π«§ Check https://beyondgrep.com/community/ for all the details π
β¨ FAQ β¨
Frequently asked questions, bestie, let's gooo π§
π Can I stop using grep now?
Many people find ack better than grep as an everyday tool 99% of the time, but don't throw grep away! There are times you'll still need it. For example, you might be digging through huge log files without using regular expressions. In that case, grep will probably perform better π
π Why isn't ack finding a match in (some file)?
First, check whether ack is even looking at the file. ack is smart about which files it searches and which ones it skips, but sometimes that can be surprising π
Use the -f switch, with no regex, to see a list of the files ack will search for you. If your file doesn't show up in that list, then ack never looks in it π«Ά
π Wouldn't it be great if ack did search & replace?
No, ack will always be read-only. Perl already has a perfectly good way to do search & replace in files, using the -i, -p and -n switches β¨
You can still use ack to pick out the files you want 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)
π§© Can I make ack recognize .xyz files?
Yes! Please check out "Defining your own types" in the ack manual π
π Will you make ack recognize .xyz files by default?
We might, depending on how widely used the file format is π€·
Submit an issue 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've 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 π
π Why is it called ack if it's called ack-grep?
The program's name is "ack". Some packagers have called it "ack-grep" when making 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
π€· What does ack mean?
Nothing! I wanted a name that was easy to type and that you could pronounce as a single syllable π
π« Can I do multi-line regexes?
No, ack does not support regexes that match multiple lines. Doing that would mean 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 π¦
β Why is ack telling me I have an invalid option when searching for "+foo"?
ack treats command line options beginning with + or - as options. If you want to search for these, you can prefix your search term with -- or use the --match option. (But don't forget that + is a regex metacharacter!) π§
π’ Why does ack '.{40000,}' fail? Isn't that a valid regex?
Perl limits the repetition quantifier to 32K. You can search for .{32767} but not .{32768} π
π§ Ack does "X" and shouldn't, should it?
We try to stay as close to grep's behavior as possible, so when in doubt, see what grep does! If there's a mismatch in functionality, please submit an issue to GitHub, and/or bring it up on the ack-users mailing list π«Ά
β¨ ACKNOWLEDGEMENTS β¨
How appropriate to have acknowledgements! π₯Ήπ Thanks to everyone who has contributed to ack in any way, including Dmitri Vereshchagin, Geraint Edwards, Loren Howard, Yaroslav Halchenko, Thiago Perrotta, Thomas Gossler, Kieran Mace, Volker Glave, Axel Beckert, Eric Pement, Gabor Szabo, Frieder Bluemle, Grzegorz Kaczmarczyk, Dan Book, Tomasz Konojacki, Salomon Smeke, M. Scott Ford, Anders Eriksson, H.Merijn Brand, Duke Leto, Gerhard Poul, Ethan Mallove, Marek Kubica, Ray Donnelly, Nikolaj Schumacher, Ed Avis, Nick Morrott, Austin Chamberlin, Varadinsky, SΓ©bastien FeugΓ¨re, Jakub Wilk, Pete Houston, Stephen Thirlwall, Jonah Bishop, Chris Rebert, Denis Howe, RaΓΊl GundΓn, James McCoy, Daniel Perrett, Steven Lee, Jonathan Perret, Fraser Tweedale, RaΓ‘l GundΓ‘n, Steffen Jaeckel, Stephan Hohe, Michael Beijen, Alexandr Ciornii, Christian Walde, Charles Lee, Joe McMahon, John Warwick, David Steinbrunner, Kara Martens, Volodymyr Medvid, Ron Savage, Konrad Borowski, Dale Sedivic, Michael McClimon, Andrew Black, Ralph Bodenner, Shaun Patterson, Ryan Olson, Shlomi Fish, Karen Etheridge, Olivier Mengue, Matthew Wild, Scott Kyle, Nick Hooey, Bo Borgerson, Mark Szymanski, Marq Schneider, Packy Anderson, JR Boyens, Dan Sully, Ryan Niebur, Kent Fredric, Mike Morearty, Ingmar Vanhassel, Eric Van Dewoestine, Sitaram Chamarty, Adam James, Richard Carlsson, Pedro Melo, AJ Schuster, Phil Jackson, Michael Schwern, Jan Dubois, Christopher J. Madsen, Matthew Wickline, David Dyck, Jason Porritt, Jjgod Jiang, Thomas Klausner, Uri Guttman, Peter Lewis, Kevin Riggle, Ori Avtalion, Torsten Blix, Nigel Metheringham, GΓ‘bor SzabΓ³, Tod Hagan, Michael Hendricks, Γvar ArnfjΓΆrΓ° Bjarmason, Piers Cawley, Stephen Steneker, Elias Lutfallah, Mark Leighton Fisher, Matt Diephouse, Christian Jaeger, Bill Sully, Bill Ricker, David Golden, Nilson Santos F. Jr, Elliot Shank, Merijn Broeren, Uwe Voelker, Rick Scott, Ask BjΓΈrn Hansen, Jerry Gay, Will Coleda, Mike O'Regan, Slaven ReziΔ, Mark Stosberg, David Alan Pisoni, Adriano Ferreira, James Keenan, Leland Johnson, Ricardo Signes, Pete Krawczyk and Rob Hoelz π«Άβ¨
β¨ AUTHOR β¨
Andy Lester, "<andy at petdance.com>" π
β¨ COPYRIGHT & LICENSE β¨
Copyright 2005-2026 Andy Lester πΈ
This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License v2.0 π
See https://www.perlfoundation.org/artistic-license-20.html or the LICENSE.md file that comes with the ack distribution π¦
And that's the whole page, bestie! π Made from perl v5.42.2 and dated 2026-06-07, so you know it's fresh π Now go ack something iconic π
β¨
π¦ where this page comes from
- fedora 43: ack 3.10.0-1.fc43 Β· Artistic-2.0
- fedora 44: ack 3.10.0-1.fc44 Β· Artistic-2.0
- π girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms