1ACK(1) User Contributed Perl Documentation ACK(1)
2
3
4
6 ack - grep-like text finder
7
9 ack [options] PATTERN [FILE...]
10 ack -f [options] [DIRECTORY...]
11
13 ack is designed as an alternative to grep for programmers.
14
15 ack searches the named input files or directories for lines containing
16 a match to the given PATTERN. By default, ack prints the matching
17 lines. If no FILE or DIRECTORY is given, the current directory will be
18 searched.
19
20 PATTERN is a Perl regular expression. Perl regular expressions are
21 commonly found in other programming languages, but for the particulars
22 of their behavior, please consult
23 <http://perldoc.perl.org/perlreref.html|perlreref>. If you don't know
24 how to use regular expression but are interested in learning, you may
25 consult <http://perldoc.perl.org/perlretut.html|perlretut>. If you do
26 not need or want ack to use regular expressions, please see the
27 "-Q"/"--literal" option.
28
29 Ack can also list files that would be searched, without actually
30 searching them, to let you take advantage of ack's file-type filtering
31 capabilities.
32
34 If files are not specified for searching, either on the command line or
35 piped in with the "-x" option, ack delves into subdirectories selecting
36 files for searching.
37
38 ack is intelligent about the files it searches. It knows about certain
39 file types, based on both the extension on the file and, in some cases,
40 the contents of the file. These selections can be made with the --type
41 option.
42
43 With no file selection, ack searches through regular files that are not
44 explicitly excluded by --ignore-dir and --ignore-file options, either
45 present in ackrc files or on the command line.
46
47 The default options for ack ignore certain files and directories.
48 These include:
49
50 · Backup files: Files matching #*# or ending with ~.
51
52 · Coredumps: Files matching core.\d+
53
54 · Version control directories like .svn and .git.
55
56 Run ack with the "--dump" option to see what settings are set.
57
58 However, ack always searches the files given on the command line, no
59 matter what type. If you tell ack to search in a coredump, it will
60 search in a coredump.
61
63 ack descends through the directory tree of the starting directories
64 specified. If no directories are specified, the current working
65 directory is used. However, it will ignore the shadow directories used
66 by many version control systems, and the build directories used by the
67 Perl MakeMaker system. You may add or remove a directory from this
68 list with the --[no]ignore-dir option. The option may be repeated to
69 add/remove multiple directories from the ignore list.
70
71 For a complete list of directories that do not get searched, run "ack
72 --dump".
73
75 ack trumps grep as an everyday tool 99% of the time, but don't throw
76 grep away, because there are times you'll still need it.
77
78 E.g., searching through huge files looking for regexes that can be
79 expressed with grep syntax should be quicker with grep.
80
81 If your script or parent program uses grep "--quiet" or "--silent" or
82 needs exit 2 on IO error, use grep.
83
85 --ackrc
86 Specifies an ackrc file to load after all others; see "ACKRC
87 LOCATION SEMANTICS".
88
89 -A NUM, --after-context=NUM
90 Print NUM lines of trailing context after matching lines.
91
92 -B NUM, --before-context=NUM
93 Print NUM lines of leading context before matching lines.
94
95 --[no]break
96 Print a break between results from different files. On by default
97 when used interactively.
98
99 -C [NUM], --context[=NUM]
100 Print NUM lines (default 2) of context around matching lines. You
101 can specify zero lines of context to override another context
102 specified in an ackrc.
103
104 -c, --count
105 Suppress normal output; instead print a count of matching lines for
106 each input file. If -l is in effect, it will only show the number
107 of lines for each file that has lines matching. Without -l, some
108 line counts may be zeroes.
109
110 If combined with -h (--no-filename) ack outputs only one total
111 count.
112
113 --[no]color, --[no]colour
114 --color highlights the matching text. --nocolor suppresses the
115 color. This is on by default unless the output is redirected.
116
117 On Windows, this option is off by default unless the
118 Win32::Console::ANSI module is installed or the "ACK_PAGER_COLOR"
119 environment variable is used.
120
121 --color-filename=color
122 Sets the color to be used for filenames.
123
124 --color-match=color
125 Sets the color to be used for matches.
126
127 --color-lineno=color
128 Sets the color to be used for line numbers.
129
130 --[no]column
131 Show the column number of the first match. This is helpful for
132 editors that can place your cursor at a given position.
133
134 --create-ackrc
135 Dumps the default ack options to standard output. This is useful
136 for when you want to customize the defaults.
137
138 --dump
139 Writes the list of options loaded and where they came from to
140 standard output. Handy for debugging.
141
142 --[no]env
143 --noenv disables all environment processing. No .ackrc is read and
144 all environment variables are ignored. By default, ack considers
145 .ackrc and settings in the environment.
146
147 --flush
148 --flush flushes output immediately. This is off by default unless
149 ack is running interactively (when output goes to a pipe or file).
150
151 -f Only print the files that would be searched, without actually doing
152 any searching. PATTERN must not be specified, or it will be taken
153 as a path to search.
154
155 --files-from=FILE
156 The list of files to be searched is specified in FILE. The list of
157 files are separated by newlines. If FILE is "-", the list is
158 loaded from standard input.
159
160 --[no]filter
161 Forces ack to act as if it were receiving input via a pipe.
162
163 --[no]follow
164 Follow or don't follow symlinks, other than whatever starting files
165 or directories were specified on the command line.
166
167 This is off by default.
168
169 -g PATTERN
170 Print searchable files where the relative path + filename matches
171 PATTERN.
172
173 Note that
174
175 ack -g foo
176
177 is exactly the same as
178
179 ack -f | ack foo
180
181 This means that just as ack will not search, for example, .jpg
182 files, "-g" will not list .jpg files either. ack is not intended
183 to be a general-purpose file finder.
184
185 Note also that if you have "-i" in your .ackrc that the filenames
186 to be matched will be case-insensitive as well.
187
188 This option can be combined with --color to make it easier to spot
189 the match.
190
191 --[no]group
192 --group groups matches by file name. This is the default when used
193 interactively.
194
195 --nogroup prints one result per line, like grep. This is the
196 default when output is redirected.
197
198 -H, --with-filename
199 Print the filename for each match. This is the default unless
200 searching a single explicitly specified file.
201
202 -h, --no-filename
203 Suppress the prefixing of filenames on output when multiple files
204 are searched.
205
206 --[no]heading
207 Print a filename heading above each file's results. This is the
208 default when used interactively.
209
210 --help, -?
211 Print a short help statement.
212
213 --help-types, --help=types
214 Print all known types.
215
216 -i, --ignore-case
217 Ignore case distinctions in PATTERN
218
219 --ignore-ack-defaults
220 Tells ack to completely ignore the default definitions provided
221 with ack. This is useful in combination with --create-ackrc if you
222 really want to customize ack.
223
224 --[no]ignore-dir=DIRNAME, --[no]ignore-directory=DIRNAME
225 Ignore directory (as CVS, .svn, etc are ignored). May be used
226 multiple times to ignore multiple directories. For example, mason
227 users may wish to include --ignore-dir=data. The --noignore-dir
228 option allows users to search directories which would normally be
229 ignored (perhaps to research the contents of .svn/props
230 directories).
231
232 The DIRNAME must always be a simple directory name. Nested
233 directories like foo/bar are NOT supported. You would need to
234 specify --ignore-dir=foo and then no files from any foo directory
235 are taken into account by ack unless given explicitly on the
236 command line.
237
238 --ignore-file=FILTERTYPE:FILTERARGS
239 Ignore files matching FILTERTYPE:FILTERARGS. The filters are
240 specified identically to file type filters as seen in "Defining
241 your own types".
242
243 -k, --known-types
244 Limit selected files to those with types that ack knows about.
245 This is equivalent to the default behavior found in ack 1.
246
247 --lines=NUM
248 Only print line NUM of each file. Multiple lines can be given with
249 multiple --lines options or as a comma separated list
250 (--lines=3,5,7). --lines=4-7 also works, as well as any
251 combination (--lines=3,15-20,43) The lines are always output in
252 ascending order, no matter the order given on the command line. No
253 pattern is matched.
254
255 -l, --files-with-matches
256 Only print the filenames of matching files, instead of the matching
257 text.
258
259 -L, --files-without-matches
260 Only print the filenames of files that do NOT match.
261
262 --match PATTERN
263 Specify the PATTERN explicitly. This is helpful if you don't want
264 to put the regex as your first argument, e.g. when executing
265 multiple searches over the same set of files.
266
267 # search for foo and bar in given files
268 ack file1 t/file* --match foo
269 ack file1 t/file* --match bar
270
271 -m=NUM, --max-count=NUM
272 Stop reading a file after NUM matches.
273
274 --man
275 Print this manual page.
276
277 -n, --no-recurse
278 No descending into subdirectories.
279
280 -o Show only the part of each line matching PATTERN (turns off text
281 highlighting)
282
283 --output=expr
284 Output the evaluation of expr for each line (turns off text
285 highlighting) If PATTERN matches more than once then a line is
286 output for each non-overlapping match. For more information please
287 see the section "Examples of --output".
288
289 --pager=program, --nopager
290 --pager directs ack's output through program. This can also be
291 specified via the "ACK_PAGER" and "ACK_PAGER_COLOR" environment
292 variables.
293
294 Using --pager does not suppress grouping and coloring like piping
295 output on the command-line does.
296
297 --nopager cancels any setting in ~/.ackrc, "ACK_PAGER" or
298 "ACK_PAGER_COLOR". No output will be sent through a pager.
299
300 --passthru
301 Prints all lines, whether or not they match the expression.
302 Highlighting will still work, though, so it can be used to
303 highlight matches while still seeing the entire file, as in:
304
305 # Watch a log file, and highlight a certain IP address
306 $ tail -f ~/access.log | ack --passthru 123.45.67.89
307
308 --print0
309 Only works in conjunction with -f, -g, -l or -c (filename output).
310 The filenames are output separated with a null byte instead of the
311 usual newline. This is helpful when dealing with filenames that
312 contain whitespace, e.g.
313
314 # remove all files of type html
315 ack -f --html --print0 | xargs -0 rm -f
316
317 -Q, --literal
318 Quote all metacharacters in PATTERN, it is treated as a literal.
319
320 -r, -R, --recurse
321 Recurse into sub-directories. This is the default and just here for
322 compatibility with grep. You can also use it for turning
323 --no-recurse off.
324
325 -s Suppress error messages about nonexistent or unreadable files.
326 This is taken from fgrep.
327
328 --[no]smart-case, --no-smart-case
329 Ignore case in the search strings if PATTERN contains no uppercase
330 characters. This is similar to "smartcase" in vim. This option is
331 off by default, and ignored if "-i" is specified.
332
333 -i always overrides this option.
334
335 --sort-files
336 Sorts the found files lexicographically. Use this if you want your
337 file listings to be deterministic between runs of ack.
338
339 --show-types
340 Outputs the filetypes that ack associates with each file.
341
342 Works with -f and -g options.
343
344 --type=[no]TYPE
345 Specify the types of files to include or exclude from a search.
346 TYPE is a filetype, like perl or xml. --type=perl can also be
347 specified as --perl, and --type=noperl can be done as --noperl.
348
349 If a file is of both type "foo" and "bar", specifying --foo and
350 --nobar will exclude the file, because an exclusion takes
351 precedence over an inclusion.
352
353 Type specifications can be repeated and are ORed together.
354
355 See ack --help=types for a list of valid types.
356
357 --type-add TYPE:FILTER:FILTERARGS
358 Files with the given FILTERARGS applied to the given FILTER are
359 recognized as being of (the existing) type TYPE. See also
360 "Defining your own types".
361
362 --type-set TYPE:FILTER:FILTERARGS
363 Files with the given FILTERARGS applied to the given FILTER are
364 recognized as being of type TYPE. This replaces an existing
365 definition for type TYPE. See also "Defining your own types".
366
367 --type-del TYPE
368 The filters associated with TYPE are removed from Ack, and are no
369 longer considered for searches.
370
371 -v, --invert-match
372 Invert match: select non-matching lines
373
374 --version
375 Display version and copyright information.
376
377 -w, --word-regexp
378 Turn on "words mode". This sometimes matches a whole word, but the
379 semantics is quite subtle. If the passed regexp begins with a word
380 character, then a word boundary is required before the match. If
381 the passed regexp ends with a word character, or with a word
382 character followed by newline, then a word boundary is required
383 after the match.
384
385 Thus, for example, -w with the regular expression "ox" will not
386 match the strings "box" or "oxen". However, if the regular
387 expression is "(ox|ass)" then it will match those strings. Because
388 the regular expression's first character is "(", the -w flag has no
389 effect at the start, and because the last character is ")", it has
390 no effect at the end.
391
392 Force PATTERN to match only whole words. The PATTERN is wrapped
393 with "\b" metacharacters.
394
395 -x An abbreviation for --files-from=-; the list of files to search are
396 read from standard input, with one line per file.
397
398 -1 Stops after reporting first match of any kind. This is different
399 from --max-count=1 or -m1, where only one match per file is shown.
400 Also, -1 works with -f and -g, where -m does not.
401
402 --thpppt
403 Display the all-important Bill The Cat logo. Note that the exact
404 spelling of --thpppppt is not important. It's checked against a
405 regular expression.
406
407 --bar
408 Check with the admiral for traps.
409
410 --cathy
411 Chocolate, Chocolate, Chocolate!
412
414 The .ackrc file contains command-line options that are prepended to the
415 command line before processing. Multiple options may live on multiple
416 lines. Lines beginning with a # are ignored. A .ackrc might look like
417 this:
418
419 # Always sort the files
420 --sort-files
421
422 # Always color, even if piping to another program
423 --color
424
425 # Use "less -r" as my pager
426 --pager=less -r
427
428 Note that arguments with spaces in them do not need to be quoted, as
429 they are not interpreted by the shell. Basically, each line in the
430 .ackrc file is interpreted as one element of @ARGV.
431
432 ack looks in several locations for .ackrc files; the searching process
433 is detailed in "ACKRC LOCATION SEMANTICS". These files are not
434 considered if --noenv is specified on the command line.
435
437 ack allows you to define your own types in addition to the predefined
438 types. This is done with command line options that are best put into an
439 .ackrc file - then you do not have to define your types over and over
440 again. In the following examples the options will always be shown on
441 one command line so that they can be easily copy & pasted.
442
443 File types can be specified both with the the --type=xxx option, or the
444 file type as an option itself. For example, if you create a filetype
445 of "cobol", you can specify --type=cobol or simply --cobol. File types
446 must be at least two characters long. This is why the C language is
447 --cc and the R language is --rr.
448
449 ack --perl foo searches for foo in all perl files. ack --help=types
450 tells you, that perl files are files ending in .pl, .pm, .pod or .t. So
451 what if you would like to include .xs files as well when searching for
452 --perl files? ack --type-add perl:ext:xs --perl foo does this for you.
453 --type-add appends additional extensions to an existing type.
454
455 If you want to define a new type, or completely redefine an existing
456 type, then use --type-set. ack --type-set eiffel:ext:e,eiffel defines
457 the type eiffel to include files with the extensions .e or .eiffel. So
458 to search for all eiffel files containing the word Bertrand use ack
459 --type-set eiffel:ext:e,eiffel --eiffel Bertrand. As usual, you can
460 also write --type=eiffel instead of --eiffel. Negation also works, so
461 --noeiffel excludes all eiffel files from a search. Redefining also
462 works: ack --type-set cc:ext:c,h and .xs files no longer belong to the
463 type cc.
464
465 When defining your own types in the .ackrc file you have to use the
466 following:
467
468 --type-set=eiffel:ext:e,eiffel
469
470 or writing on separate lines
471
472 --type-set
473 eiffel:ext:e,eiffel
474
475 The following does NOT work in the .ackrc file:
476
477 --type-set eiffel:ext:e,eiffel
478
479 In order to see all currently defined types, use --help-types, e.g.
480 ack --type-set backup:ext:bak --type-add perl:ext:perl --help-types
481
482 In addition to filtering based on extension (like ack 1.x allowed), ack
483 2 offers additional filter types. The generic syntax is --type-set
484 TYPE:FILTER:FILTERARGS; FILTERARGS depends on the value of FILTER.
485
486 is:FILENAME
487 is filters match the target filename exactly. It takes exactly one
488 argument, which is the name of the file to match.
489
490 Example:
491
492 --type-set make:is:Makefile
493
494 ext:EXTENSION[,EXTENSION2[,...]]
495 ext filters match the extension of the target file against a list
496 of extensions. No leading dot is needed for the extensions.
497
498 Example:
499
500 --type-set perl:ext:pl,pm,t
501
502 match:PATTERN
503 match filters match the target filename against a regular
504 expression. The regular expression is made case insensitive for
505 the search.
506
507 Example:
508
509 --type-set make:match:/(gnu)?makefile/
510
511 firstlinematch:PATTERN
512 firstlinematch matches the first line of the target file against a
513 regular expression. Like match, the regular expression is made
514 case insensitive.
515
516 Example:
517
518 --type-add perl:firstlinematch:/perl/
519
520 More filter types may be made available in the future.
521
523 For commonly-used ack options, environment variables can make life much
524 easier. These variables are ignored if --noenv is specified on the
525 command line.
526
527 ACKRC
528 Specifies the location of the user's .ackrc file. If this file
529 doesn't exist, ack looks in the default location.
530
531 ACK_OPTIONS
532 This variable specifies default options to be placed in front of
533 any explicit options on the command line.
534
535 ACK_COLOR_FILENAME
536 Specifies the color of the filename when it's printed in --group
537 mode. By default, it's "bold green".
538
539 The recognized attributes are clear, reset, dark, bold, underline,
540 underscore, blink, reverse, concealed black, red, green, yellow,
541 blue, magenta, on_black, on_red, on_green, on_yellow, on_blue,
542 on_magenta, on_cyan, and on_white. Case is not significant.
543 Underline and underscore are equivalent, as are clear and reset.
544 The color alone sets the foreground color, and on_color sets the
545 background color.
546
547 This option can also be set with --color-filename.
548
549 ACK_COLOR_MATCH
550 Specifies the color of the matching text when printed in --color
551 mode. By default, it's "black on_yellow".
552
553 This option can also be set with --color-match.
554
555 See ACK_COLOR_FILENAME for the color specifications.
556
557 ACK_COLOR_LINENO
558 Specifies the color of the line number when printed in --color
559 mode. By default, it's "bold yellow".
560
561 This option can also be set with --color-lineno.
562
563 See ACK_COLOR_FILENAME for the color specifications.
564
565 ACK_PAGER
566 Specifies a pager program, such as "more", "less" or "most", to
567 which ack will send its output.
568
569 Using "ACK_PAGER" does not suppress grouping and coloring like
570 piping output on the command-line does, except that on Windows ack
571 will assume that "ACK_PAGER" does not support color.
572
573 "ACK_PAGER_COLOR" overrides "ACK_PAGER" if both are specified.
574
575 ACK_PAGER_COLOR
576 Specifies a pager program that understands ANSI color sequences.
577 Using "ACK_PAGER_COLOR" does not suppress grouping and coloring
578 like piping output on the command-line does.
579
580 If you are not on Windows, you never need to use "ACK_PAGER_COLOR".
581
583 ack uses the colors available in Perl's Term::ANSIColor module, which
584 provides the following listed values. Note that case does not matter
585 when using these values.
586
587 Foreground colors
588 black red green yellow blue magenta cyan white
589
590 bright_black bright_red bright_green bright_yellow
591 bright_blue bright_magenta bright_cyan bright_white
592
593 Background colors
594 on_black on_red on_green on_yellow
595 on_blue on_magenta on_cyan on_white
596
597 on_bright_black on_bright_red on_bright_green on_bright_yellow
598 on_bright_blue on_bright_magenta on_bright_cyan on_bright_white
599
601 Simple vim integration
602 ack integrates easily with the Vim text editor. Set this in your .vimrc
603 to use ack instead of grep:
604
605 set grepprg=ack\ -k
606
607 That example uses "-k" to search through only files of the types ack
608 knows about, but you may use other default flags. Now you can search
609 with ack and easily step through the results in Vim:
610
611 :grep Dumper perllib
612
613 Editor integration
614 Many users have integrated ack into their preferred text editors. For
615 details and links, see <https://beyondgrep.com/more-tools/>.
616
617 Shell and Return Code
618 For greater compatibility with grep, ack in normal use returns shell
619 return or exit code of 0 only if something is found and 1 if no match
620 is found.
621
622 (Shell exit code 1 is "$?=256" in perl with "system" or backticks.)
623
624 The grep code 2 for errors is not used.
625
626 If "-f" or "-g" are specified, then 0 is returned if at least one file
627 is found. If no files are found, then 1 is returned.
628
630 If ack gives you output you're not expecting, start with a few simple
631 steps.
632
633 Use --noenv
634 Your environment variables and .ackrc may be doing things you're not
635 expecting, or forgotten you specified. Use --noenv to ignore your
636 environment and .ackrc.
637
638 Use -f to see what files have been selected
639 Ack's -f was originally added as a debugging tool. If ack is not
640 finding matches you think it should find, run ack -f to see what files
641 have been selected. You can also add the "--show-types" options to
642 show the type of each file selected.
643
644 Use --dump
645 This lists the ackrc files that are loaded and the options loaded from
646 them. So for example you can find a list of directories that do not
647 get searched or where filetypes are defined.
648
650 Use the .ackrc file.
651 The .ackrc is the place to put all your options you use most of the
652 time but don't want to remember. Put all your --type-add and
653 --type-set definitions in it. If you like --smart-case, set it there,
654 too. I also set --sort-files there.
655
656 Use -f for working with big codesets
657 Ack does more than search files. "ack -f --perl" will create a list of
658 all the Perl files in a tree, ideal for sending into xargs. For
659 example:
660
661 # Change all "this" to "that" in all Perl files in a tree.
662 ack -f --perl | xargs perl -p -i -e's/this/that/g'
663
664 or if you prefer:
665
666 perl -p -i -e's/this/that/g' $(ack -f --perl)
667
668 Use -Q when in doubt about metacharacters
669 If you're searching for something with a regular expression
670 metacharacter, most often a period in a filename or IP address, add the
671 -Q to avoid false positives without all the backslashing. See the
672 following example for more...
673
674 Use ack to watch log files
675 Here's one I used the other day to find trouble spots for a website
676 visitor. The user had a problem loading troublesome.gif, so I took the
677 access log and scanned it with ack twice.
678
679 ack -Q aa.bb.cc.dd /path/to/access.log | ack -Q -B5 troublesome.gif
680
681 The first ack finds only the lines in the Apache log for the given IP.
682 The second finds the match on my troublesome GIF, and shows the
683 previous five lines from the log in each case.
684
685 Examples of --output
686 Following variables are useful in the expansion string:
687
688 $& The whole string matched by PATTERN.
689
690 $1, $2, ...
691 The contents of the 1st, 2nd ... bracketed group in PATTERN.
692
693 "$`"
694 The string before the match.
695
696 "$'"
697 The string after the match.
698
699 For more details and other variables see
700 <http://perldoc.perl.org/perlvar.html#Variables-related-to-regular-expressions|perlvar>.
701
702 This example shows how to add text around a particular pattern (in this
703 case adding _ around word with "e")
704
705 ack2.pl "\w*e\w*" quick.txt --output="$`_$&_$'"
706 _The_ quick brown fox jumps over the lazy dog
707 The quick brown fox jumps _over_ the lazy dog
708 The quick brown fox jumps over _the_ lazy dog
709
710 This shows how to pick out particular parts of a match using ( ) within
711 regular expression.
712
713 ack '=head(\d+)\s+(.*)' --output=' $1 : $2'
714 input file contains "=head1 NAME"
715 output "1 : NAME"
716
718 There are ack mailing lists and a Slack channel for ack. See
719 <https://beyondgrep.com/community/> for details.
720
722 Why isn't ack finding a match in (some file)?
723 First, take a look and see if ack is even looking at the file. ack is
724 intelligent in what files it will search and which ones it won't, but
725 sometimes that can be surprising.
726
727 Use the "-f" switch, with no regex, to see a list of files that ack
728 will search for you. If your file doesn't show up in the list of files
729 that "ack -f" shows, then ack never looks in it.
730
731 NOTE: If you're using an old ack before 2.0, it's probably because it's
732 of a type that ack doesn't recognize. In ack 1.x, the searching
733 behavior is driven by filetype. If ack 1.x doesn't know what kind of
734 file it is, ack ignores the file. You can use the "--show-types"
735 switch to show which type ack thinks each file is.
736
737 Wouldn't it be great if ack did search & replace?
738 No, ack will always be read-only. Perl has a perfectly good way to do
739 search & replace in files, using the "-i", "-p" and "-n" switches.
740
741 You can certainly use ack to select your files to update. For example,
742 to change all "foo" to "bar" in all PHP files, you can do this from the
743 Unix shell:
744
745 $ perl -i -p -e's/foo/bar/g' $(ack -f --php)
746
747 Can I make ack recognize .xyz files?
748 Yes! Please see "Defining your own types". If you think that ack
749 should recognize a type by default, please see "ENHANCEMENTS".
750
751 There's already a program/package called ack.
752 Yes, I know.
753
754 Why is it called ack if it's called ack-grep?
755 The name of the program is "ack". Some packagers have called it "ack-
756 grep" when creating packages because there's already a package out
757 there called "ack" that has nothing to do with this ack.
758
759 I suggest you make a symlink named ack that points to ack-grep because
760 one of the crucial benefits of ack is having a name that's so short and
761 simple to type.
762
763 To do that, run this with sudo or as root:
764
765 ln -s /usr/bin/ack-grep /usr/bin/ack
766
767 Alternatively, you could use a shell alias:
768
769 # bash/zsh
770 alias ack=ack-grep
771
772 # csh
773 alias ack ack-grep
774
775 What does ack mean?
776 Nothing. I wanted a name that was easy to type and that you could
777 pronounce as a single syllable.
778
779 Can I do multi-line regexes?
780 No, ack does not support regexes that match multiple lines. Doing so
781 would require reading in the entire file at a time.
782
783 If you want to see lines near your match, use the "--A", "--B" and
784 "--C" switches for displaying context.
785
786 Why is ack telling me I have an invalid option when searching for "+foo"?
787 ack treats command line options beginning with "+" or "-" as options;
788 if you would like to search for these, you may prefix your search term
789 with "--" or use the "--match" option. (However, don't forget that "+"
790 is a regular expression metacharacter!)
791
792 Why does "ack '.{40000,}'" fail? Isn't that a valid regex?
793 The Perl language limits the repetition quantifier to 32K. You can
794 search for ".{32767}" but not ".{32768}".
795
796 Ack does "X" and shouldn't, should it?
797 We try to remain as close to grep's behavior as possible, so when in
798 doubt, see what grep does! If there's a mismatch in functionality
799 there, please bring it up on the ack-users mailing list.
800
802 Ack can load its configuration from many sources. The following list
803 specifies the sources Ack looks for configuration files; each one that
804 is found is loaded in the order specified here, and each one overrides
805 options set in any of the sources preceding it. (For example, if I set
806 --sort-files in my user ackrc, and --nosort-files on the command line,
807 the command line takes precedence)
808
809 · Defaults are loaded from App::Ack::ConfigDefaults. This can be
810 omitted using "--ignore-ack-defaults".
811
812 · Global ackrc
813
814 Options are then loaded from the global ackrc. This is located at
815 "/etc/ackrc" on Unix-like systems.
816
817 Under Windows XP and earlier, the global ackrc is at "C:\Documents
818 and Settings\All Users\Application Data\ackrc"
819
820 Under Windows Vista/7, the global ackrc is at
821 "C:\ProgramData\ackrc"
822
823 The "--noenv" option prevents all ackrc files from being loaded.
824
825 · User ackrc
826
827 Options are then loaded from the user's ackrc. This is located at
828 "$HOME/.ackrc" on Unix-like systems.
829
830 Under Windows XP and earlier, the user's ackrc is at "C:\Documents
831 and Settings\$USER\Application Data\ackrc".
832
833 Under Windows Vista/7, the user's ackrc is at
834 "C:\Users\$USER\AppData\Roaming\ackrc".
835
836 If you want to load a different user-level ackrc, it may be
837 specified with the $ACKRC environment variable.
838
839 The "--noenv" option prevents all ackrc files from being loaded.
840
841 · Project ackrc
842
843 Options are then loaded from the project ackrc. The project ackrc
844 is the first ackrc file with the name ".ackrc" or "_ackrc", first
845 searching in the current directory, then the parent directory, then
846 the grandparent directory, etc. This can be omitted using
847 "--noenv".
848
849 · --ackrc
850
851 The "--ackrc" option may be included on the command line to specify
852 an ackrc file that can override all others. It is consulted even
853 if "--noenv" is present.
854
855 · ACK_OPTIONS
856
857 Options are then loaded from the environment variable
858 "ACK_OPTIONS". This can be omitted using "--noenv".
859
860 · Command line
861
862 Options are then loaded from the command line.
863
865 A lot of changes were made for ack 2; here is a list of them.
866
867 GENERAL CHANGES
868 · When no selectors are specified, ack 1.x only searches through
869 files that it can map to a file type. ack 2.x, by contrast, will
870 search through every regular, non-binary file that is not
871 explicitly ignored via --ignore-file or --ignore-dir. This is
872 similar to the behavior of the -a/--all option in ack 1.x.
873
874 · A more flexible filter system has been added, so that more powerful
875 file types may be created by the user. For details, please consult
876 "Defining your own types".
877
878 · ack now loads multiple ackrc files; see "ACKRC LOCATION SEMANTICS"
879 for details.
880
881 · ack's default filter definitions aren't special; you may tell ack
882 to completely disregard them if you don't like them.
883
884 REMOVED OPTIONS
885 · Because of the change in default search behavior, the -a/--all and
886 -u/--unrestricted options have been removed. In addition, the
887 -k/--known-types option was added to cause ack to behave with the
888 default search behavior of ack 1.x.
889
890 · The -G option has been removed. Two regular expressions on the
891 command line was considered too confusing; to simulate -G's
892 functionality, you may use the new -x option to pipe filenames from
893 one invocation of ack into another.
894
895 · The --binary option has been removed.
896
897 · The --skipped option has been removed.
898
899 · The --text option has been removed.
900
901 · The --invert-file-match option has been removed. Instead, you may
902 use -v with -g.
903
904 CHANGED OPTIONS
905 · The options that modify the regular expression's behavior (-i, -w,
906 -Q, and -v) may now be used with -g.
907
908 ADDED OPTIONS
909 · --files-from was added so that a user may submit a list of
910 filenames as a list of files to search.
911
912 · -x was added to tell ack to accept a list of filenames via standard
913 input; this list is the list of filenames that will be used for the
914 search.
915
916 · -s was added to tell ack to suppress error messages about non-
917 existent or unreadable files.
918
919 · --ignore-directory and --noignore-directory were added as aliases
920 for --ignore-dir and --noignore-dir respectively.
921
922 · --ignore-file was added so that users may specify patterns of files
923 to ignore (ex. /.*~$/).
924
925 · --dump was added to allow users to easily find out which options
926 are set where.
927
928 · --create-ackrc was added so that users may create custom ackrc
929 files based on the default settings loaded by ack, and so that
930 users may easily view those defaults.
931
932 · --type-del was added to selectively remove file type definitions.
933
934 · --ignore-ack-defaults was added so that users may ignore ack's
935 default options in favor of their own.
936
937 · --bar was added so ack users may consult Admiral Ackbar.
938
940 Andy Lester, "<andy at petdance.com>"
941
943 Please report any bugs or feature requests to the issues list at
944 Github: <https://github.com/beyondgrep/ack2/issues>
945
947 All enhancement requests MUST first be posted to the ack-users mailing
948 list at <http://groups.google.com/group/ack-users>. I will not
949 consider a request without it first getting seen by other ack users.
950 This includes requests for new filetypes.
951
952 There is a list of enhancements I want to make to ack in the ack issues
953 list at Github: <https://github.com/beyondgrep/ack2/issues>
954
955 Patches are always welcome, but patches with tests get the most
956 attention.
957
959 Support for and information about ack can be found at:
960
961 · The ack homepage
962
963 <https://beyondgrep.com/>
964
965 · The ack-users mailing list
966
967 <http://groups.google.com/group/ack-users>
968
969 · The ack issues list at Github
970
971 <https://github.com/beyondgrep/ack2/issues>
972
973 · AnnoCPAN: Annotated CPAN documentation
974
975 <http://annocpan.org/dist/ack>
976
977 · CPAN Ratings
978
979 <http://cpanratings.perl.org/d/ack>
980
981 · Search CPAN
982
983 <http://search.cpan.org/dist/ack>
984
985 · MetaCPAN
986
987 <http://metacpan.org/release/ack>
988
989 · Git source repository
990
991 <https://github.com/beyondgrep/ack2>
992
994 How appropriate to have acknowledgements!
995
996 Thanks to everyone who has contributed to ack in any way, including Tim
997 Gim Yee, Michele Campeotto, H.Merijn Brand, Duke Leto, Gerhard Poul,
998 Ethan Mallove, Marek Kubica, Ray Donnelly, Nikolaj Schumacher, Ed Avis,
999 Nick Morrott, Austin Chamberlin, Varadinsky, Sébastien Feugère, Jakub
1000 Wilk, Pete Houston, Stephen Thirlwall, Jonah Bishop, Chris Rebert,
1001 Denis Howe, Raúl Gundín, James McCoy, Daniel Perrett, Steven Lee,
1002 Jonathan Perret, Fraser Tweedale, Raál Gundán, Steffen Jaeckel, Stephan
1003 Hohe, Michael Beijen, Alexandr Ciornii, Christian Walde, Charles Lee,
1004 Joe McMahon, John Warwick, David Steinbrunner, Kara Martens, Volodymyr
1005 Medvid, Ron Savage, Konrad Borowski, Dale Sedivic, Michael McClimon,
1006 Andrew Black, Ralph Bodenner, Shaun Patterson, Ryan Olson, Shlomi Fish,
1007 Karen Etheridge, Olivier Mengue, Matthew Wild, Scott Kyle, Nick Hooey,
1008 Bo Borgerson, Mark Szymanski, Marq Schneider, Packy Anderson, JR
1009 Boyens, Dan Sully, Ryan Niebur, Kent Fredric, Mike Morearty, Ingmar
1010 Vanhassel, Eric Van Dewoestine, Sitaram Chamarty, Adam James, Richard
1011 Carlsson, Pedro Melo, AJ Schuster, Phil Jackson, Michael Schwern, Jan
1012 Dubois, Christopher J. Madsen, Matthew Wickline, David Dyck, Jason
1013 Porritt, Jjgod Jiang, Thomas Klausner, Uri Guttman, Peter Lewis, Kevin
1014 Riggle, Ori Avtalion, Torsten Blix, Nigel Metheringham, Gábor Szabó,
1015 Tod Hagan, Michael Hendricks, Ævar Arnfjörð Bjarmason, Piers Cawley,
1016 Stephen Steneker, Elias Lutfallah, Mark Leighton Fisher, Matt
1017 Diephouse, Christian Jaeger, Bill Sully, Bill Ricker, David Golden,
1018 Nilson Santos F. Jr, Elliot Shank, Merijn Broeren, Uwe Voelker, Rick
1019 Scott, Ask Bjørn Hansen, Jerry Gay, Will Coleda, Mike O'Regan, Slaven
1020 Rezić, Mark Stosberg, David Alan Pisoni, Adriano Ferreira, James
1021 Keenan, Leland Johnson, Ricardo Signes, Pete Krawczyk and Rob Hoelz.
1022
1024 Copyright 2005-2019 Andy Lester.
1025
1026 This program is free software; you can redistribute it and/or modify it
1027 under the terms of the Artistic License v2.0.
1028
1029 See http://www.perlfoundation.org/artistic_license_2_0 or the
1030 LICENSE.md file that comes with the ack distribution.
1031
1032
1033
1034perl v5.28.1 2019-03-18 ACK(1)