1AG(1) AG(1)
2
3
4
6 ag - The Silver Searcher. Like ack, but faster.
7
9 ag [options] pattern [path ...]
10
12 Recursively search for PATTERN in PATH. Like grep or ack, but faster.
13
15 --ackmate
16 Output results in a format parseable by AckMate
17 https://github.com/protocool/AckMate.
18
19 --[no]affinity
20 Set thread affinity (if platform supports it). Default is true.
21
22 -a --all-types
23 Search all files. This doesn´t include hidden files, and doesn´t
24 respect any ignore files.
25
26 -A --after [LINES]
27 Print lines after match. If not provided, LINES defaults to 2.
28
29 -B --before [LINES]
30 Print lines before match. If not provided, LINES defaults to 2.
31
32 --[no]break
33 Print a newline between matches in different files. Enabled by
34 default.
35
36 -c --count
37 Only print the number of matches in each file. Note: This is the
38 number of matches, not the number of matching lines. Pipe output
39 to wc -l if you want the number of matching lines.
40
41 --[no]color
42 Print color codes in results. Enabled by default.
43
44 --color-line-number
45 Color codes for line numbers. Default is 1;33.
46
47 --color-match
48 Color codes for result match numbers. Default is 30;43.
49
50 --color-path
51 Color codes for path names. Default is 1;32.
52
53 --column
54 Print column numbers in results.
55
56 -C --context [LINES]
57 Print lines before and after matches. Default is 2.
58
59 -D --debug
60 Output ridiculous amounts of debugging info. Not useful unless
61 you´re actually debugging.
62
63 --depth NUM
64 Search up to NUM directories deep, -1 for unlimited. Default is
65 25.
66
67 --[no]filename
68 Print file names. Enabled by default, except when searching a
69 single file.
70
71 -f --[no]follow
72 Follow symlinks. Default is false.
73
74 -F --fixed-strings
75 Alias for --literal for compatibility with grep.
76
77 --[no]group
78 The default, --group, lumps multiple matches in the same file
79 together, and presents them under a single occurrence of the
80 filename. --nogroup refrains from this, and instead places the
81 filename at the start of each match line.
82
83 -g PATTERN
84 Print filenames matching PATTERN.
85
86 -G --file-search-regex PATTERN
87 Only search files whose names match PATTERN.
88
89 -H --[no]heading
90 Print filenames above matching contents.
91
92 --hidden
93 Search hidden files. This option obeys ignored files.
94
95 --ignore PATTERN
96 Ignore files/directories whose names match this pattern. Literal
97 file and directory names are also allowed.
98
99 --ignore-dir NAME
100 Alias for --ignore for compatibility with ack.
101
102 -i --ignore-case
103 Match case-insensitively.
104
105 -l --files-with-matches
106 Only print the names of files containing matches, not the match‐
107 ing lines. An empty query will print all files that would be
108 searched.
109
110 -L --files-without-matches
111 Only print the names of files that don´t contain matches.
112
113 --list-file-types
114 See FILE TYPES below.
115
116 -m --max-count NUM
117 Skip the rest of a file after NUM matches. Default is 0, which
118 never skips.
119
120 --[no]mmap
121 Toggle use of memory-mapped I/O. Defaults to true on platforms
122 where mmap() is faster than read(). (All but macOS.)
123
124 --[no]multiline
125 Match regexes across newlines. Enabled by default.
126
127 -n --norecurse
128 Don´t recurse into directories.
129
130 --[no]numbers
131 Print line numbers. Default is to omit line numbers when search‐
132 ing streams.
133
134 -o --only-matching
135 Print only the matching part of the lines.
136
137 --one-device
138 When recursing directories, don´t scan dirs that reside on other
139 storage devices. This lets you avoid scanning slow network
140 mounts. This feature is not supported on all platforms.
141
142 -p --path-to-ignore STRING
143 Provide a path to a specific .ignore file.
144
145 --pager COMMAND
146 Use a pager such as less. Use --nopager to override. This option
147 is also ignored if output is piped to another program.
148
149 --parallel
150 Parse the input stream as a search term, not data to search.
151 This is meant to be used with tools such as GNU parallel. For
152 example: echo "foo\nbar\nbaz" | parallel "ag {} ." will run 3
153 instances of ag, searching the current directory for "foo",
154 "bar", and "baz".
155
156 --print-long-lines
157 Print matches on very long lines (> 2k characters by default).
158
159 --passthrough --passthru
160 When searching a stream, print all lines even if they don´t
161 match.
162
163 -Q --literal
164 Do not parse PATTERN as a regular expression. Try to match it
165 literally.
166
167 -r --recurse
168 Recurse into directories when searching. Default is true.
169
170 -s --case-sensitive
171 Match case-sensitively.
172
173 -S --smart-case
174 Match case-sensitively if there are any uppercase letters in
175 PATTERN, case-insensitively otherwise. Enabled by default.
176
177 --search-binary
178 Search binary files for matches.
179
180 --silent
181 Suppress all log messages, including errors.
182
183 --stats
184 Print stats (files scanned, time taken, etc).
185
186 --stats-only
187 Print stats (files scanned, time taken, etc) and nothing else.
188
189 -t --all-text
190 Search all text files. This doesn´t include hidden files.
191
192 -u --unrestricted
193 Search all files. This ignores .ignore, .gitignore, etc. It
194 searches binary and hidden files as well.
195
196 -U --skip-vcs-ignores
197 Ignore VCS ignore files (.gitignore, .hgignore), but still use
198 .ignore.
199
200 -v --invert-match
201 Match every line not containing the specified pattern.
202
203 -V --version
204 Print version info.
205
206 --vimgrep
207 Output results in the same form as Vim´s :vimgrep /pattern/g
208
209 Here is a ~/.vimrc configuration example:
210
211 set grepprg=ag\ --vimgrep\ $* set grepformat=%f:%l:%c:%m
212
213 Then use :grep to grep for something. Then use :copen, :cn, :cp,
214 etc. to navigate through the matches.
215
216 -w --word-regexp
217 Only match whole words.
218
219 --workers NUM
220 Use NUM worker threads. Default is the number of CPU cores, with
221 a max of 8.
222
223 -z --search-zip
224 Search contents of compressed files. Currently, gz and xz are
225 supported. This option requires that ag is built with lzma and
226 zlib.
227
228 -0 --null --print0
229 Separate the filenames with \0, rather than \n: this allows
230 xargs -0 <command> to correctly process filenames containing
231 spaces or newlines.
232
234 It is possible to restrict the types of files searched. For example,
235 passing --html will search only files with the extensions htm, html,
236 shtml or xhtml. For a list of supported types, run ag
237 --list-file-types.
238
240 By default, ag will ignore files whose names match patterns in .gitig‐
241 nore, .hgignore, or .ignore. These files can be anywhere in the direc‐
242 tories being searched. Binary files are ignored by default as well.
243 Finally, ag looks in $HOME/.agignore for ignore patterns.
244
245 If you want to ignore .gitignore and .hgignore, but still take .ignore
246 into account, use -U.
247
248 Use the -t option to search all text files; -a to search all files; and
249 -u to search all, including hidden files.
250
252 ag printf: Find matches for "printf" in the current directory.
253
254 ag foo /bar/: Find matches for "foo" in path /bar/.
255
256 ag -- --foo: Find matches for "--foo" in the current directory. (As
257 with most UNIX command line utilities, "--" is used to signify that the
258 remaining arguments should not be treated as options.)
259
261 ag was originally created by Geoff Greer. More information (and the
262 latest release) can be found at http://geoff.greer.fm/ag
263
265 grep(1)
266
267
268
269 December 2016 AG(1)