1RG(1) RG(1)
2
3
4
6 rg - recursively search current directory for lines matching a pattern
7
9 rg [OPTIONS] PATTERN [PATH...]
10
11 rg [OPTIONS] -e PATTERN... [PATH...]
12
13 rg [OPTIONS] -f PATTERNFILE... [PATH...]
14
15 rg [OPTIONS] --files [PATH...]
16
17 rg [OPTIONS] --type-list
18
19 command | rg [OPTIONS] PATTERN
20
21 rg [OPTIONS] --help
22
23 rg [OPTIONS] --version
24
26 ripgrep (rg) recursively searches your current directory for a regex
27 pattern. By default, ripgrep will respect your .gitignore and
28 automatically skip hidden files/directories and binary files.
29
30 ripgrep’s default regex engine uses finite automata and guarantees
31 linear time searching. Because of this, features like backreferences
32 and arbitrary look-around are not supported. However, if ripgrep is
33 built with PCRE2, then the --pcre2 flag can be used to enable
34 backreferences and look-around.
35
36 ripgrep supports configuration files. Set RIPGREP_CONFIG_PATH to a
37 configuration file. The file can specify one shell argument per line.
38 Lines starting with # are ignored. For more details, see the man page
39 or the README.
40
41 ripgrep will automatically detect if stdin exists and search stdin for
42 a regex pattern, e.g. ls | rg foo. In some environments, stdin may
43 exist when it shouldn’t. To turn off stdin detection explicitly specify
44 the directory to search, e.g. rg foo ./.
45
46 Tip: to disable all smart filtering and make ripgrep behave a bit more
47 like classical grep, use rg -uuu.
48
50 ripgrep uses Rust’s regex engine by default, which documents its
51 syntax: https://docs.rs/regex/*/regex/#syntax
52
53 ripgrep uses byte-oriented regexes, which has some additional
54 documentation: https://docs.rs/regex/*/regex/bytes/index.html#syntax
55
56 To a first approximation, ripgrep uses Perl-like regexes without
57 look-around or backreferences. This makes them very similar to the
58 "extended" (ERE) regular expressions supported by egrep, but with a few
59 additional features like Unicode character classes.
60
61 If you’re using ripgrep with the --pcre2 flag, then please consult
62 https://www.pcre.org or the PCRE2 man pages for documentation on the
63 supported syntax.
64
66 PATTERN
67 A regular expression used for searching. To match a pattern
68 beginning with a dash, use the -e/--regexp option.
69
70 PATH
71 A file or directory to search. Directories are searched
72 recursively. File paths specified explicitly on the command line
73 override glob and ignore rules.
74
76 Note that for many options, there exist flags to disable them. In some
77 cases, those flags are not listed in a first class way below. For
78 example, the --column flag (listed below) enables column numbers in
79 ripgrep’s output, but the --no-column flag (not listed below) disables
80 them. The reverse can also exist. For example, the --no-ignore flag
81 (listed below) disables ripgrep’s gitignore logic, but the --ignore
82 flag (not listed below) enables it. These flags are useful for
83 overriding a ripgrep configuration file on the command line. Each
84 flag’s documentation notes whether an inverted flag exists. In all
85 cases, the flag specified last takes precedence.
86
87 -A, --after-context NUM
88 Show NUM lines after each match.
89
90 This overrides the --context flag.
91
92 --auto-hybrid-regex
93 DEPRECATED. Use --engine instead.
94
95 When this flag is used, ripgrep will dynamically choose between
96 supported regex engines depending on the features used in a
97 pattern. When ripgrep chooses a regex engine, it applies that
98 choice for every regex provided to ripgrep (e.g., via multiple
99 -e/--regexp or -f/--file flags).
100
101 As an example of how this flag might behave, ripgrep will attempt
102 to use its default finite automata based regex engine whenever the
103 pattern can be successfully compiled with that regex engine. If
104 PCRE2 is enabled and if the pattern given could not be compiled
105 with the default regex engine, then PCRE2 will be automatically
106 used for searching. If PCRE2 isn’t available, then this flag has no
107 effect because there is only one regex engine to choose from.
108
109 In the future, ripgrep may adjust its heuristics for how it decides
110 which regex engine to use. In general, the heuristics will be
111 limited to a static analysis of the patterns, and not to any
112 specific runtime behavior observed while searching files.
113
114 The primary downside of using this flag is that it may not always
115 be obvious which regex engine ripgrep uses, and thus, the match
116 semantics or performance profile of ripgrep may subtly and
117 unexpectedly change. However, in many cases, all regex engines will
118 agree on what constitutes a match and it can be nice to
119 transparently support more advanced regex features like look-around
120 and backreferences without explicitly needing to enable them.
121
122 This flag can be disabled with --no-auto-hybrid-regex.
123
124 -B, --before-context NUM
125 Show NUM lines before each match.
126
127 This overrides the --context flag.
128
129 --binary
130 Enabling this flag will cause ripgrep to search binary files. By
131 default, ripgrep attempts to automatically skip binary files in
132 order to improve the relevance of results and make the search
133 faster.
134
135 Binary files are heuristically detected based on whether they
136 contain a NUL byte or not. By default (without this flag set), once
137 a NUL byte is seen, ripgrep will stop searching the file. Usually,
138 NUL bytes occur in the beginning of most binary files. If a NUL
139 byte occurs after a match, then ripgrep will still stop searching
140 the rest of the file, but a warning will be printed.
141
142 In contrast, when this flag is provided, ripgrep will continue
143 searching a file even if a NUL byte is found. In particular, if a
144 NUL byte is found then ripgrep will continue searching until either
145 a match is found or the end of the file is reached, whichever comes
146 sooner. If a match is found, then ripgrep will stop and print a
147 warning saying that the search stopped prematurely.
148
149 If you want ripgrep to search a file without any special NUL byte
150 handling at all (and potentially print binary data to stdout), then
151 you should use the -a/--text flag.
152
153 The --binary flag is a flag for controlling ripgrep’s automatic
154 filtering mechanism. As such, it does not need to be used when
155 searching a file explicitly or when searching stdin. That is, it is
156 only applicable when recursively searching a directory.
157
158 Note that when the -u/--unrestricted flag is provided for a third
159 time, then this flag is automatically enabled.
160
161 This flag can be disabled with --no-binary. It overrides the
162 -a/--text flag.
163
164 --block-buffered
165 When enabled, ripgrep will use block buffering. That is, whenever a
166 matching line is found, it will be written to an in-memory buffer
167 and will not be written to stdout until the buffer reaches a
168 certain size. This is the default when ripgrep’s stdout is
169 redirected to a pipeline or a file. When ripgrep’s stdout is
170 connected to a terminal, line buffering will be used. Forcing block
171 buffering can be useful when dumping a large amount of contents to
172 a terminal.
173
174 Forceful block buffering can be disabled with --no-block-buffered.
175 Note that using --no-block-buffered causes ripgrep to revert to its
176 default behavior of automatically detecting the buffering strategy.
177 To force line buffering, use the --line-buffered flag.
178
179 -b, --byte-offset
180 Print the 0-based byte offset within the input file before each
181 line of output. If -o (--only-matching) is specified, print the
182 offset of the matching part itself.
183
184 If ripgrep does transcoding, then the byte offset is in terms of
185 the the result of transcoding and not the original data. This
186 applies similarly to another transformation on the source, such as
187 decompression or a --pre filter. Note that when the PCRE2 regex
188 engine is used, then UTF-8 transcoding is done by default.
189
190 -s, --case-sensitive
191 Search case sensitively.
192
193 This overrides the -i/--ignore-case and -S/--smart-case flags.
194
195 --color WHEN
196 This flag controls when to use colors. The default setting is auto,
197 which means ripgrep will try to guess when to use colors. For
198 example, if ripgrep is printing to a terminal, then it will use
199 colors, but if it is redirected to a file or a pipe, then it will
200 suppress color output. ripgrep will suppress color output in some
201 other circumstances as well. For example, if the TERM environment
202 variable is not set or set to dumb, then ripgrep will not use
203 colors.
204
205 The possible values for this flag are:
206
207 never Colors will never be used.
208 auto The default. ripgrep tries to be smart.
209 always Colors will always be used regardless of where output is sent.
210 ansi Like 'always', but emits ANSI escapes (even in a Windows console).
211
212 When the --vimgrep flag is given to ripgrep, then the default value
213 for the --color flag changes to never.
214
215 --colors COLOR_SPEC ...
216 This flag specifies color settings for use in the output. This flag
217 may be provided multiple times. Settings are applied iteratively.
218 Colors are limited to one of eight choices: red, blue, green, cyan,
219 magenta, yellow, white and black. Styles are limited to nobold,
220 bold, nointense, intense, nounderline or underline.
221
222 The format of the flag is {type}:{attribute}:{value}. {type} should
223 be one of path, line, column or match. {attribute} can be fg, bg or
224 style. {value} is either a color (for fg and bg) or a text style. A
225 special format, {type}:none, will clear all color settings for
226 {type}.
227
228 For example, the following command will change the match color to
229 magenta and the background color for line numbers to yellow:
230
231 rg --colors 'match:fg:magenta' --colors 'line:bg:yellow' foo.
232
233 Extended colors can be used for {value} when the terminal supports
234 ANSI color sequences. These are specified as either x (256-color)
235 or x,x,x (24-bit truecolor) where x is a number between 0 and 255
236 inclusive. x may be given as a normal decimal number or a
237 hexadecimal number, which is prefixed by 0x.
238
239 For example, the following command will change the match background
240 color to that represented by the rgb value (0,128,255):
241
242 rg --colors 'match:bg:0,128,255'
243
244 or, equivalently,
245
246 rg --colors 'match:bg:0x0,0x80,0xFF'
247
248 Note that the the intense and nointense style flags will have no
249 effect when used alongside these extended color codes.
250
251 --column
252 Show column numbers (1-based). This only shows the column numbers
253 for the first match on each line. This does not try to account for
254 Unicode. One byte is equal to one column. This implies
255 --line-number.
256
257 This flag can be disabled with --no-column.
258
259 -C, --context NUM
260 Show NUM lines before and after each match. This is equivalent to
261 providing both the -B/--before-context and -A/--after-context flags
262 with the same value.
263
264 This overrides both the -B/--before-context and -A/--after-context
265 flags.
266
267 --context-separator SEPARATOR
268 The string used to separate non-contiguous context lines in the
269 output. This is only used when one of the context flags is used
270 (-A, -B or -C). Escape sequences like \x7F or \t may be used. The
271 default value is --.
272
273 When the context separator is set to an empty string, then a line
274 break is still inserted. To completely disable context separators,
275 use the --no-context-separator flag.
276
277 -c, --count
278 This flag suppresses normal output and shows the number of lines
279 that match the given patterns for each file searched. Each file
280 containing a match has its path and count printed on each line.
281 Note that this reports the number of lines that match and not the
282 total number of matches.
283
284 If only one file is given to ripgrep, then only the count is
285 printed if there is a match. The --with-filename flag can be used
286 to force printing the file path in this case.
287
288 This overrides the --count-matches flag. Note that when --count is
289 combined with --only-matching, then ripgrep behaves as if
290 --count-matches was given.
291
292 --count-matches
293 This flag suppresses normal output and shows the number of
294 individual matches of the given patterns for each file searched.
295 Each file containing matches has its path and match count printed
296 on each line. Note that this reports the total number of individual
297 matches and not the number of lines that match.
298
299 If only one file is given to ripgrep, then only the count is
300 printed if there is a match. The --with-filename flag can be used
301 to force printing the file path in this case.
302
303 This overrides the --count flag. Note that when --count is combined
304 with --only-matching, then ripgrep behaves as if --count-matches
305 was given.
306
307 --crlf
308 When enabled, ripgrep will treat CRLF (\r\n) as a line terminator
309 instead of just \n.
310
311 Principally, this permits $ in regex patterns to match just before
312 CRLF instead of just before LF. The underlying regex engine may not
313 support this natively, so ripgrep will translate all instances of $
314 to (?:\r??$). This may produce slightly different than desired
315 match offsets. It is intended as a work-around until the regex
316 engine supports this natively.
317
318 CRLF support can be disabled with --no-crlf.
319
320 --debug
321 Show debug messages. Please use this when filing a bug report.
322
323 The --debug flag is generally useful for figuring out why ripgrep
324 skipped searching a particular file. The debug messages should
325 mention all files skipped and why they were skipped.
326
327 To get even more debug output, use the --trace flag, which implies
328 --debug along with additional trace data. With --trace, the output
329 could be quite large and is generally more useful for development.
330
331 --dfa-size-limit NUM+SUFFIX?
332 The upper size limit of the regex DFA. The default limit is 10M.
333 This should only be changed on very large regex inputs where the
334 (slower) fallback regex engine may otherwise be used if the limit
335 is reached.
336
337 The argument accepts the same size suffixes as allowed in with the
338 --max-filesize flag.
339
340 -E, --encoding ENCODING
341 Specify the text encoding that ripgrep will use on all files
342 searched. The default value is auto, which will cause ripgrep to do
343 a best effort automatic detection of encoding on a per-file basis.
344 Automatic detection in this case only applies to files that begin
345 with a UTF-8 or UTF-16 byte-order mark (BOM). No other automatic
346 detection is performed. One can also specify none which will then
347 completely disable BOM sniffing and always result in searching the
348 raw bytes, including a BOM if it’s present, regardless of its
349 encoding.
350
351 Other supported values can be found in the list of labels here:
352 https://encoding.spec.whatwg.org/#concept-encoding-get
353
354 For more details on encoding and how ripgrep deals with it, see
355 GUIDE.md.
356
357 This flag can be disabled with --no-encoding.
358
359 --engine ENGINE
360 Specify which regular expression engine to use. When you choose a
361 regex engine, it applies that choice for every regex provided to
362 ripgrep (e.g., via multiple -e/--regexp or -f/--file flags).
363
364 Accepted values are default, pcre2, or auto.
365
366 The default value is default, which is the fastest and should be
367 good for most use cases. The pcre2 engine is generally useful when
368 you want to use features such as look-around or backreferences.
369 auto will dynamically choose between supported regex engines
370 depending on the features used in a pattern on a best effort basis.
371
372 Note that the pcre2 engine is an optional ripgrep feature. If PCRE2
373 wasn’t including in your build of ripgrep, then using this flag
374 will result in ripgrep printing an error message and exiting.
375
376 This overrides previous uses of --pcre2 and --auto-hybrid-regex
377 flags.
378
379 -f, --file PATTERNFILE ...
380 Search for patterns from the given file, with one pattern per line.
381 When this flag is used multiple times or in combination with the
382 -e/--regexp flag, then all patterns provided are searched. Empty
383 pattern lines will match all input lines, and the newline is not
384 counted as part of the pattern.
385
386 A line is printed if and only if it matches at least one of the
387 patterns.
388
389 --files
390 Print each file that would be searched without actually performing
391 the search. This is useful to determine whether a particular file
392 is being searched or not.
393
394 -l, --files-with-matches
395 Only print the paths with at least one match.
396
397 This overrides --files-without-match.
398
399 --files-without-match
400 Only print the paths that contain zero matches. This
401 inverts/negates the --files-with-matches flag.
402
403 This overrides --files-with-matches.
404
405 -F, --fixed-strings
406 Treat the pattern as a literal string instead of a regular
407 expression. When this flag is used, special regular expression meta
408 characters such as .(){}*+ do not need to be escaped.
409
410 This flag can be disabled with --no-fixed-strings.
411
412 -L, --follow
413 When this flag is enabled, ripgrep will follow symbolic links while
414 traversing directories. This is disabled by default. Note that
415 ripgrep will check for symbolic link loops and report errors if it
416 finds one.
417
418 This flag can be disabled with --no-follow.
419
420 -g, --glob GLOB ...
421 Include or exclude files and directories for searching that match
422 the given glob. This always overrides any other ignore logic.
423 Multiple glob flags may be used. Globbing rules match .gitignore
424 globs. Precede a glob with a ! to exclude it. If multiple globs
425 match a file or directory, the glob given later in the command line
426 takes precedence.
427
428 When this flag is set, every file and directory is applied to it to
429 test for a match. So for example, if you only want to search in a
430 particular directory foo, then -g foo is incorrect because foo/bar
431 does not match the glob foo. Instead, you should use -g 'foo/**'.
432
433 --glob-case-insensitive
434 Process glob patterns given with the -g/--glob flag case
435 insensitively. This effectively treats --glob as --iglob.
436
437 This flag can be disabled with the --no-glob-case-insensitive flag.
438
439 --heading
440 This flag prints the file path above clusters of matches from each
441 file instead of printing the file path as a prefix for each matched
442 line. This is the default mode when printing to a terminal.
443
444 This overrides the --no-heading flag.
445
446 --hidden
447 Search hidden files and directories. By default, hidden files and
448 directories are skipped. Note that if a hidden file or a directory
449 is whitelisted in an ignore file, then it will be searched even if
450 this flag isn’t provided.
451
452 This flag can be disabled with --no-hidden.
453
454 --iglob GLOB ...
455 Include or exclude files and directories for searching that match
456 the given glob. This always overrides any other ignore logic.
457 Multiple glob flags may be used. Globbing rules match .gitignore
458 globs. Precede a glob with a ! to exclude it. Globs are matched
459 case insensitively.
460
461 -i, --ignore-case
462 When this flag is provided, the given patterns will be searched
463 case insensitively. The case insensitivity rules used by ripgrep
464 conform to Unicode’s "simple" case folding rules.
465
466 This flag overrides -s/--case-sensitive and -S/--smart-case.
467
468 --ignore-file PATH ...
469 Specifies a path to one or more .gitignore format rules files.
470 These patterns are applied after the patterns found in .gitignore
471 and .ignore are applied and are matched relative to the current
472 working directory. Multiple additional ignore files can be
473 specified by using the --ignore-file flag several times. When
474 specifying multiple ignore files, earlier files have lower
475 precedence than later files.
476
477 If you are looking for a way to include or exclude files and
478 directories directly on the command line, then used -g instead.
479
480 --ignore-file-case-insensitive
481 Process ignore files (.gitignore, .ignore, etc.) case
482 insensitively. Note that this comes with a performance penalty and
483 is most useful on case insensitive file systems (such as Windows).
484
485 This flag can be disabled with the
486 --no-ignore-file-case-insensitive flag.
487
488 --include-zero
489 When used with --count or --count-matches, print the number of
490 matches for each file even if there were zero matches. This is
491 disabled by default but can be enabled to make ripgrep behave more
492 like grep.
493
494 -v, --invert-match
495 Invert matching. Show lines that do not match the given patterns.
496
497 --json
498 Enable printing results in a JSON Lines format.
499
500 When this flag is provided, ripgrep will emit a sequence of
501 messages, each encoded as a JSON object, where there are five
502 different message types:
503
504 begin - A message that indicates a file is being searched and
505 contains at least one match.
506
507 end - A message the indicates a file is done being searched. This
508 message also include summary statistics about the search for a
509 particular file.
510
511 match - A message that indicates a match was found. This includes
512 the text and offsets of the match.
513
514 context - A message that indicates a contextual line was found.
515 This includes the text of the line, along with any match
516 information if the search was inverted.
517
518 summary - The final message emitted by ripgrep that contains
519 summary statistics about the search across all files.
520
521 Since file paths or the contents of files are not guaranteed to be
522 valid UTF-8 and JSON itself must be representable by a Unicode
523 encoding, ripgrep will emit all data elements as objects with one
524 of two keys: text or bytes. text is a normal JSON string when the
525 data is valid UTF-8 while bytes is the base64 encoded contents of
526 the data.
527
528 The JSON Lines format is only supported for showing search results.
529 It cannot be used with other flags that emit other types of output,
530 such as --files, --files-with-matches, --files-without-match,
531 --count or --count-matches. ripgrep will report an error if any of
532 the aforementioned flags are used in concert with --json.
533
534 Other flags that control aspects of the standard output such as
535 --only-matching, --heading, --replace, --max-columns, etc., have no
536 effect when --json is set.
537
538 A more complete description of the JSON format used can be found
539 here: https://docs.rs/grep-printer/*/grep_printer/struct.JSON.html
540
541 The JSON Lines format can be disabled with --no-json.
542
543 --line-buffered
544 When enabled, ripgrep will use line buffering. That is, whenever a
545 matching line is found, it will be flushed to stdout immediately.
546 This is the default when ripgrep’s stdout is connected to a
547 terminal, but otherwise, ripgrep will use block buffering, which is
548 typically faster. This flag forces ripgrep to use line buffering
549 even if it would otherwise use block buffering. This is typically
550 useful in shell pipelines, e.g., tail -f something.log | rg foo
551 --line-buffered | rg bar.
552
553 Forceful line buffering can be disabled with --no-line-buffered.
554 Note that using --no-line-buffered causes ripgrep to revert to its
555 default behavior of automatically detecting the buffering strategy.
556 To force block buffering, use the --block-buffered flag.
557
558 -n, --line-number
559 Show line numbers (1-based). This is enabled by default when
560 searching in a terminal.
561
562 -x, --line-regexp
563 Only show matches surrounded by line boundaries. This is equivalent
564 to putting ^...$ around all of the search patterns. In other words,
565 this only prints lines where the entire line participates in a
566 match.
567
568 This overrides the --word-regexp flag.
569
570 -M, --max-columns NUM
571 Don’t print lines longer than this limit in bytes. Longer lines are
572 omitted, and only the number of matches in that line is printed.
573
574 When this flag is omitted or is set to 0, then it has no effect.
575
576 --max-columns-preview
577 When the --max-columns flag is used, ripgrep will by default
578 completely replace any line that is too long with a message
579 indicating that a matching line was removed. When this flag is
580 combined with --max-columns, a preview of the line (corresponding
581 to the limit size) is shown instead, where the part of the line
582 exceeding the limit is not shown.
583
584 If the --max-columns flag is not set, then this has no effect.
585
586 This flag can be disabled with --no-max-columns-preview.
587
588 -m, --max-count NUM
589 Limit the number of matching lines per file searched to NUM.
590
591 --max-depth NUM
592 Limit the depth of directory traversal to NUM levels beyond the
593 paths given. A value of zero only searches the explicitly given
594 paths themselves.
595
596 For example, rg --max-depth 0 dir/ is a no-op because dir/ will not
597 be descended into. rg --max-depth 1 dir/ will search only the
598 direct children of dir.
599
600 --max-filesize NUM+SUFFIX?
601 Ignore files larger than NUM in size. This does not apply to
602 directories.
603
604 The input format accepts suffixes of K, M or G which correspond to
605 kilobytes, megabytes and gigabytes, respectively. If no suffix is
606 provided the input is treated as bytes.
607
608 Examples: --max-filesize 50K or --max-filesize 80M
609
610 --mmap
611 Search using memory maps when possible. This is enabled by default
612 when ripgrep thinks it will be faster.
613
614 Memory map searching doesn’t currently support all options, so if
615 an incompatible option (e.g., --context) is given with --mmap, then
616 memory maps will not be used.
617
618 Note that ripgrep may abort unexpectedly when --mmap if it searches
619 a file that is simultaneously truncated.
620
621 This flag overrides --no-mmap.
622
623 -U, --multiline
624 Enable matching across multiple lines.
625
626 When multiline mode is enabled, ripgrep will lift the restriction
627 that a match cannot include a line terminator. For example, when
628 multiline mode is not enabled (the default), then the regex \p{any}
629 will match any Unicode codepoint other than \n. Similarly, the
630 regex \n is explicitly forbidden, and if you try to use it, ripgrep
631 will return an error. However, when multiline mode is enabled,
632 \p{any} will match any Unicode codepoint, including \n, and regexes
633 like \n are permitted.
634
635 An important caveat is that multiline mode does not change the
636 match semantics of .. Namely, in most regex matchers, a . will by
637 default match any character other than \n, and this is true in
638 ripgrep as well. In order to make . match \n, you must enable the
639 "dot all" flag inside the regex. For example, both (?s). and (?s:.)
640 have the same semantics, where . will match any character,
641 including \n. Alternatively, the --multiline-dotall flag may be
642 passed to make the "dot all" behavior the default. This flag only
643 applies when multiline search is enabled.
644
645 There is no limit on the number of the lines that a single match
646 can span.
647
648 WARNING: Because of how the underlying regex engine works,
649 multiline searches may be slower than normal line-oriented
650 searches, and they may also use more memory. In particular, when
651 multiline mode is enabled, ripgrep requires that each file it
652 searches is laid out contiguously in memory (either by reading it
653 onto the heap or by memory-mapping it). Things that cannot be
654 memory-mapped (such as stdin) will be consumed until EOF before
655 searching can begin. In general, ripgrep will only do these things
656 when necessary. Specifically, if the --multiline flag is provided
657 but the regex does not contain patterns that would match \n
658 characters, then ripgrep will automatically avoid reading each file
659 into memory before searching it. Nevertheless, if you only care
660 about matches spanning at most one line, then it is always better
661 to disable multiline mode.
662
663 This flag can be disabled with --no-multiline.
664
665 --multiline-dotall
666 This flag enables "dot all" in your regex pattern, which causes .
667 to match newlines when multiline searching is enabled. This flag
668 has no effect if multiline searching isn’t enabled with the
669 --multiline flag.
670
671 Normally, a . will match any character except newlines. While this
672 behavior typically isn’t relevant for line-oriented matching (since
673 matches can span at most one line), this can be useful when
674 searching with the -U/--multiline flag. By default, the multiline
675 mode runs without this flag.
676
677 This flag is generally intended to be used in an alias or your
678 ripgrep config file if you prefer "dot all" semantics by default.
679 Note that regardless of whether this flag is used, "dot all"
680 semantics can still be controlled via inline flags in the regex
681 pattern itself, e.g., (?s:.) always enables "dot all" whereas
682 (?-s:.) always disables "dot all".
683
684 This flag can be disabled with --no-multiline-dotall.
685
686 --no-config
687 Never read configuration files. When this flag is present, ripgrep
688 will not respect the RIPGREP_CONFIG_PATH environment variable.
689
690 If ripgrep ever grows a feature to automatically read configuration
691 files in pre-defined locations, then this flag will also disable
692 that behavior as well.
693
694 -I, --no-filename
695 Never print the file path with the matched lines. This is the
696 default when ripgrep is explicitly instructed to search one file or
697 stdin.
698
699 This flag overrides --with-filename.
700
701 --no-heading
702 Don’t group matches by each file. If --no-heading is provided in
703 addition to the -H/--with-filename flag, then file paths will be
704 printed as a prefix for every matched line. This is the default
705 mode when not printing to a terminal.
706
707 This overrides the --heading flag.
708
709 --no-ignore
710 Don’t respect ignore files (.gitignore, .ignore, etc.). This
711 implies --no-ignore-dot, --no-ignore-exclude, --no-ignore-global,
712 no-ignore-parent and --no-ignore-vcs.
713
714 This does not imply --no-ignore-files, since --ignore-file is
715 specified explicitly as a command line argument.
716
717 This flag can be disabled with the --ignore flag.
718
719 --no-ignore-dot
720 Don’t respect .ignore files.
721
722 This flag can be disabled with the --ignore-dot flag.
723
724 --no-ignore-exclude
725 Don’t respect ignore files that are manually configured for the
726 repository such as git’s .git/info/exclude.
727
728 This flag can be disabled with the --ignore-exclude flag.
729
730 --no-ignore-files
731 When set, any --ignore-file flags, even ones that come after this
732 flag, are ignored.
733
734 This flag can be disabled with the --ignore-files flag.
735
736 --no-ignore-global
737 Don’t respect ignore files that come from "global" sources such as
738 git’s core.excludesFile configuration option (which defaults to
739 $HOME/.config/git/ignore).
740
741 This flag can be disabled with the --ignore-global flag.
742
743 --no-ignore-messages
744 Suppresses all error messages related to parsing ignore files such
745 as .ignore or .gitignore.
746
747 This flag can be disabled with the --ignore-messages flag.
748
749 --no-ignore-parent
750 Don’t respect ignore files (.gitignore, .ignore, etc.) in parent
751 directories.
752
753 This flag can be disabled with the --ignore-parent flag.
754
755 --no-ignore-vcs
756 Don’t respect version control ignore files (.gitignore, etc.). This
757 implies --no-ignore-parent for VCS files. Note that .ignore files
758 will continue to be respected.
759
760 This flag can be disabled with the --ignore-vcs flag.
761
762 -N, --no-line-number
763 Suppress line numbers. This is enabled by default when not
764 searching in a terminal.
765
766 --no-messages
767 Suppress all error messages related to opening and reading files.
768 Error messages related to the syntax of the pattern given are still
769 shown.
770
771 This flag can be disabled with the --messages flag.
772
773 --no-mmap
774 Never use memory maps, even when they might be faster.
775
776 This flag overrides --mmap.
777
778 --no-pcre2-unicode
779 DEPRECATED. Use --no-unicode instead.
780
781 This flag is now an alias for --no-unicode. And --pcre2-unicode is
782 an alias for --unicode.
783
784 --no-require-git
785 By default, ripgrep will only respect global gitignore rules,
786 .gitignore rules and local exclude rules if ripgrep detects that
787 you are searching inside a git repository. This flag allows you to
788 relax this restriction such that ripgrep will respect all git
789 related ignore rules regardless of whether you’re searching in a
790 git repository or not.
791
792 This flag can be disabled with --require-git.
793
794 --no-unicode
795 By default, ripgrep will enable "Unicode mode" in all of its
796 regexes. This has a number of consequences:
797
798 • . will only match valid UTF-8 encoded scalar values.
799
800 • Classes like \w, \s, \d are all Unicode aware and much bigger
801 than their ASCII only versions.
802
803 • Case insensitive matching will use Unicode case folding.
804
805 • A large array of classes like \p{Emoji} are available.
806
807 • Word boundaries (\b and \B) use the Unicode definition of a
808 word character.
809
810 In some cases it can be desirable to turn these things off. The
811 --no-unicode flag will do exactly that.
812
813 For PCRE2 specifically, Unicode mode represents a critical
814 trade off in the user experience of ripgrep. In particular,
815 unlike the default regex engine, PCRE2 does not support the
816 ability to search possibly invalid UTF-8 with Unicode features
817 enabled. Instead, PCRE2 requires that everything it searches
818 when Unicode mode is enabled is valid UTF-8. (Or valid
819 UTF-16/UTF-32, but for the purposes of ripgrep, we only discuss
820 UTF-8.) This means that if you have PCRE2’s Unicode mode
821 enabled and you attempt to search invalid UTF-8, then the
822 search for that file will halt and print an error. For this
823 reason, when PCRE2’s Unicode mode is enabled, ripgrep will
824 automatically "fix" invalid UTF-8 sequences by replacing them
825 with the Unicode replacement codepoint. This penalty does not
826 occur when using the default regex engine.
827
828 If you would rather see the encoding errors surfaced by PCRE2
829 when Unicode mode is enabled, then pass the --no-encoding flag
830 to disable all transcoding.
831
832 The --no-unicode flag can be disabled with --unicode. Note that
833 --no-pcre2-unicode and --pcre2-unicode are aliases for
834 --no-unicode and --unicode, respectively.
835
836 -0, --null
837 Whenever a file path is printed, follow it with a NUL byte. This
838 includes printing file paths before matches, and when printing a
839 list of matching files such as with --count, --files-with-matches
840 and --files. This option is useful for use with xargs.
841
842 --null-data
843 Enabling this option causes ripgrep to use NUL as a line terminator
844 instead of the default of \n.
845
846 This is useful when searching large binary files that would
847 otherwise have very long lines if \n were used as the line
848 terminator. In particular, ripgrep requires that, at a minimum,
849 each line must fit into memory. Using NUL instead can be a useful
850 stopgap to keep memory requirements low and avoid OOM (out of
851 memory) conditions.
852
853 This is also useful for processing NUL delimited data, such as that
854 emitted when using ripgrep’s -0/--null flag or find’s --print0
855 flag.
856
857 Using this flag implies -a/--text.
858
859 --one-file-system
860 When enabled, ripgrep will not cross file system boundaries
861 relative to where the search started from.
862
863 Note that this applies to each path argument given to ripgrep. For
864 example, in the command rg --one-file-system /foo/bar /quux/baz,
865 ripgrep will search both /foo/bar and /quux/baz even if they are on
866 different file systems, but will not cross a file system boundary
867 when traversing each path’s directory tree.
868
869 This is similar to find’s -xdev or -mount flag.
870
871 This flag can be disabled with --no-one-file-system.
872
873 -o, --only-matching
874 Print only the matched (non-empty) parts of a matching line, with
875 each such part on a separate output line.
876
877 --passthru
878 Print both matching and non-matching lines.
879
880 Another way to achieve a similar effect is by modifying your
881 pattern to match the empty string. For example, if you are
882 searching using rg foo then using rg "^|foo" instead will emit
883 every line in every file searched, but only occurrences of foo will
884 be highlighted. This flag enables the same behavior without needing
885 to modify the pattern.
886
887 --path-separator SEPARATOR
888 Set the path separator to use when printing file paths. This
889 defaults to your platform’s path separator, which is / on Unix and
890 \ on Windows. This flag is intended for overriding the default when
891 the environment demands it (e.g., cygwin). A path separator is
892 limited to a single byte.
893
894 -P, --pcre2
895 When this flag is present, ripgrep will use the PCRE2 regex engine
896 instead of its default regex engine.
897
898 This is generally useful when you want to use features such as
899 look-around or backreferences.
900
901 Note that PCRE2 is an optional ripgrep feature. If PCRE2 wasn’t
902 included in your build of ripgrep, then using this flag will result
903 in ripgrep printing an error message and exiting. PCRE2 may also
904 have worse user experience in some cases, since it has fewer
905 introspection APIs than ripgrep’s default regex engine. For
906 example, if you use a \n in a PCRE2 regex without the
907 -U/--multiline flag, then ripgrep will silently fail to match
908 anything instead of reporting an error immediately (like it does
909 with the default regex engine).
910
911 Related flags: --no-pcre2-unicode
912
913 This flag can be disabled with --no-pcre2.
914
915 --pcre2-version
916 When this flag is present, ripgrep will print the version of PCRE2
917 in use, along with other information, and then exit. If PCRE2 is
918 not available, then ripgrep will print an error message and exit
919 with an error code.
920
921 --pre COMMAND
922 For each input FILE, search the standard output of COMMAND FILE
923 rather than the contents of FILE. This option expects the COMMAND
924 program to either be an absolute path or to be available in your
925 PATH. Either an empty string COMMAND or the --no-pre flag will
926 disable this behavior.
927
928 WARNING: When this flag is set, ripgrep will unconditionally spawn a
929 process for every file that is searched. Therefore, this can incur an
930 unnecessarily large performance penalty if you don't otherwise need the
931 flexibility offered by this flag. One possible mitigation to this is to use
932 the '--pre-glob' flag to limit which files a preprocessor is run with.
933
934 A preprocessor is not run when ripgrep is searching stdin.
935
936 When searching over sets of files that may require one of several
937 decoders as preprocessors, COMMAND should be a wrapper program or
938 script which first classifies FILE based on magic numbers/content
939 or based on the FILE name and then dispatches to an appropriate
940 preprocessor. Each COMMAND also has its standard input connected to
941 FILE for convenience.
942
943 For example, a shell script for COMMAND might look like:
944
945 case "$1" in
946 *.pdf)
947 exec pdftotext "$1" -
948 ;;
949 *)
950 case $(file "$1") in
951 *Zstandard*)
952 exec pzstd -cdq
953 ;;
954 *)
955 exec cat
956 ;;
957 esac
958 ;;
959 esac
960
961 The above script uses pdftotext to convert a PDF file to plain
962 text. For all other files, the script uses the file utility to
963 sniff the type of the file based on its contents. If it is a
964 compressed file in the Zstandard format, then pzstd is used to
965 decompress the contents to stdout.
966
967 This overrides the -z/--search-zip flag.
968
969 --pre-glob GLOB ...
970 This flag works in conjunction with the --pre flag. Namely, when
971 one or more --pre-glob flags are given, then only files that match
972 the given set of globs will be handed to the command specified by
973 the --pre flag. Any non-matching files will be searched without
974 using the preprocessor command.
975
976 This flag is useful when searching many files with the --pre flag.
977 Namely, it permits the ability to avoid process overhead for files
978 that don’t need preprocessing. For example, given the following
979 shell script, pre-pdftotext:
980
981 #!/bin/sh
982
983 pdftotext "$1" -
984
985 then it is possible to use --pre pre-pdftotext --pre-glob '*.pdf'
986 to make it so ripgrep only executes the pre-pdftotext command on
987 files with a .pdf extension.
988
989 Multiple --pre-glob flags may be used. Globbing rules match
990 .gitignore globs. Precede a glob with a ! to exclude it.
991
992 This flag has no effect if the --pre flag is not used.
993
994 -p, --pretty
995 This is a convenience alias for --color always --heading
996 --line-number. This flag is useful when you still want pretty
997 output even if you’re piping ripgrep to another program or file.
998 For example: rg -p foo | less -R.
999
1000 -q, --quiet
1001 Do not print anything to stdout. If a match is found in a file,
1002 then ripgrep will stop searching. This is useful when ripgrep is
1003 used only for its exit code (which will be an error if no matches
1004 are found).
1005
1006 When --files is used, then ripgrep will stop finding files after
1007 finding the first file that matches all ignore rules.
1008
1009 --regex-size-limit NUM+SUFFIX?
1010 The upper size limit of the compiled regex. The default limit is
1011 10M.
1012
1013 The argument accepts the same size suffixes as allowed in the
1014 --max-filesize flag.
1015
1016 -e, --regexp PATTERN ...
1017 A pattern to search for. This option can be provided multiple
1018 times, where all patterns given are searched. Lines matching at
1019 least one of the provided patterns are printed. This flag can also
1020 be used when searching for patterns that start with a dash.
1021
1022 For example, to search for the literal -foo, you can use this flag:
1023
1024 rg -e -foo
1025
1026 You can also use the special -- delimiter to indicate that no more
1027 flags will be provided. Namely, the following is equivalent to the
1028 above:
1029
1030 rg -- -foo
1031
1032 -r, --replace REPLACEMENT_TEXT
1033 Replace every match with the text given when printing results.
1034 Neither this flag nor any other ripgrep flag will modify your
1035 files.
1036
1037 Capture group indices (e.g., $5) and names (e.g., $foo) are
1038 supported in the replacement string. Capture group indices are
1039 numbered based on the position of the opening paranthesis of the
1040 group, where the leftmost such group is $1. The special $0 group
1041 corresponds to the entire match.
1042
1043 In shells such as Bash and zsh, you should wrap the pattern in
1044 single quotes instead of double quotes. Otherwise, capture group
1045 indices will be replaced by expanded shell variables which will
1046 most likely be empty.
1047
1048 To write a literal $, use $$.
1049
1050 Note that the replacement by default replaces each match, and NOT
1051 the entire line. To replace the entire line, you should match the
1052 entire line.
1053
1054 This flag can be used with the -o/--only-matching flag.
1055
1056 -z, --search-zip
1057 Search in compressed files. Currently gzip, bzip2, xz, LZ4, LZMA,
1058 Brotli and Zstd files are supported. This option expects the
1059 decompression binaries to be available in your PATH.
1060
1061 This flag can be disabled with --no-search-zip.
1062
1063 -S, --smart-case
1064 Searches case insensitively if the pattern is all lowercase. Search
1065 case sensitively otherwise.
1066
1067 This overrides the -s/--case-sensitive and -i/--ignore-case flags.
1068
1069 --sort SORTBY
1070 This flag enables sorting of results in ascending order. The
1071 possible values for this flag are:
1072
1073 none (Default) Do not sort results. Fastest. Can be multi-threaded.
1074 path Sort by file path. Always single-threaded.
1075 modified Sort by the last modified time on a file. Always single-threaded.
1076 accessed Sort by the last accessed time on a file. Always single-threaded.
1077 created Sort by the creation time on a file. Always single-threaded.
1078
1079 If the chosen (manually or by-default) sorting criteria isn’t
1080 available on your system (for example, creation time is not
1081 available on ext4 file systems), then ripgrep will attempt to
1082 detect this, print an error and exit without searching.
1083
1084 To sort results in reverse or descending order, use the --sortr
1085 flag. Also, this flag overrides --sortr.
1086
1087 Note that sorting results currently always forces ripgrep to
1088 abandon parallelism and run in a single thread.
1089
1090 --sortr SORTBY
1091 This flag enables sorting of results in descending order. The
1092 possible values for this flag are:
1093
1094 none (Default) Do not sort results. Fastest. Can be multi-threaded.
1095 path Sort by file path. Always single-threaded.
1096 modified Sort by the last modified time on a file. Always single-threaded.
1097 accessed Sort by the last accessed time on a file. Always single-threaded.
1098 created Sort by the creation time on a file. Always single-threaded.
1099
1100 If the chosen (manually or by-default) sorting criteria isn’t
1101 available on your system (for example, creation time is not
1102 available on ext4 file systems), then ripgrep will attempt to
1103 detect this, print an error and exit without searching.
1104
1105 To sort results in ascending order, use the --sort flag. Also, this
1106 flag overrides --sort.
1107
1108 Note that sorting results currently always forces ripgrep to
1109 abandon parallelism and run in a single thread.
1110
1111 --stats
1112 Print aggregate statistics about this ripgrep search. When this
1113 flag is present, ripgrep will print the following stats to stdout
1114 at the end of the search: number of matched lines, number of files
1115 with matches, number of files searched, and the time taken for the
1116 entire search to complete.
1117
1118 This set of aggregate statistics may expand over time.
1119
1120 Note that this flag has no effect if --files, --files-with-matches
1121 or --files-without-match is passed.
1122
1123 This flag can be disabled with --no-stats.
1124
1125 -a, --text
1126 Search binary files as if they were text. When this flag is
1127 present, ripgrep’s binary file detection is disabled. This means
1128 that when a binary file is searched, its contents may be printed if
1129 there is a match. This may cause escape codes to be printed that
1130 alter the behavior of your terminal.
1131
1132 When binary file detection is enabled it is imperfect. In general,
1133 it uses a simple heuristic. If a NUL byte is seen during search,
1134 then the file is considered binary and search stops (unless this
1135 flag is present). Alternatively, if the --binary flag is used, then
1136 ripgrep will only quit when it sees a NUL byte after it sees a
1137 match (or searches the entire file).
1138
1139 This flag can be disabled with --no-text. It overrides the --binary
1140 flag.
1141
1142 -j, --threads NUM
1143 The approximate number of threads to use. A value of 0 (which is
1144 the default) causes ripgrep to choose the thread count using
1145 heuristics.
1146
1147 --trim
1148 When set, all ASCII whitespace at the beginning of each line
1149 printed will be trimmed.
1150
1151 This flag can be disabled with --no-trim.
1152
1153 -t, --type TYPE ...
1154 Only search files matching TYPE. Multiple type flags may be
1155 provided. Use the --type-list flag to list all available types.
1156
1157 This flag supports the special value all, which will behave as if
1158 --type was provided for every file type supported by ripgrep
1159 (including any custom file types). The end result is that --type
1160 all causes ripgrep to search in "whitelist" mode, where it will
1161 only search files it recognizes via its type definitions.
1162
1163 --type-add TYPE_SPEC ...
1164 Add a new glob for a particular file type. Only one glob can be
1165 added at a time. Multiple --type-add flags can be provided. Unless
1166 --type-clear is used, globs are added to any existing globs defined
1167 inside of ripgrep.
1168
1169 Note that this MUST be passed to every invocation of ripgrep. Type
1170 settings are NOT persisted. See CONFIGURATION FILES for a
1171 workaround.
1172
1173 Example:
1174
1175 rg --type-add 'foo:*.foo' -tfoo PATTERN.
1176
1177 --type-add can also be used to include rules from other types with
1178 the special include directive. The include directive permits
1179 specifying one or more other type names (separated by a comma) that
1180 have been defined and its rules will automatically be imported into
1181 the type specified. For example, to create a type called src that
1182 matches C++, Python and Markdown files, one can use:
1183
1184 --type-add 'src:include:cpp,py,md'
1185
1186 Additional glob rules can still be added to the src type by using
1187 the --type-add flag again:
1188
1189 --type-add 'src:include:cpp,py,md' --type-add 'src:*.foo'
1190
1191 Note that type names must consist only of Unicode letters or
1192 numbers. Punctuation characters are not allowed.
1193
1194 --type-clear TYPE ...
1195 Clear the file type globs previously defined for TYPE. This only
1196 clears the default type definitions that are found inside of
1197 ripgrep.
1198
1199 Note that this MUST be passed to every invocation of ripgrep. Type
1200 settings are NOT persisted. See CONFIGURATION FILES for a
1201 workaround.
1202
1203 --type-list
1204 Show all supported file types and their corresponding globs.
1205
1206 -T, --type-not TYPE ...
1207 Do not search files matching TYPE. Multiple type-not flags may be
1208 provided. Use the --type-list flag to list all available types.
1209
1210 -u, --unrestricted ...
1211 Reduce the level of "smart" searching. A single -u won’t respect
1212 .gitignore (etc.) files. Two -u flags will additionally search
1213 hidden files and directories. Three -u flags will additionally
1214 search binary files.
1215
1216 rg -uuu is roughly equivalent to grep -r.
1217
1218 --vimgrep
1219 Show results with every match on its own line, including line
1220 numbers and column numbers. With this option, a line with more than
1221 one match will be printed more than once.
1222
1223 -H, --with-filename
1224 Display the file path for matches. This is the default when more
1225 than one file is searched. If --heading is enabled (the default
1226 when printing to a terminal), the file path will be shown above
1227 clusters of matches from each file; otherwise, the file name will
1228 be shown as a prefix for each matched line.
1229
1230 This flag overrides --no-filename.
1231
1232 -w, --word-regexp
1233 Only show matches surrounded by word boundaries. This is roughly
1234 equivalent to putting \b before and after all of the search
1235 patterns.
1236
1237 This overrides the --line-regexp flag.
1238
1240 If ripgrep finds a match, then the exit status of the program is 0. If
1241 no match could be found, then the exit status is 1. If an error
1242 occurred, then the exit status is always 2 unless ripgrep was run with
1243 the --quiet flag and a match was found. In summary:
1244
1245 • 0 exit status occurs only when at least one match was found, and if
1246 no error occurred, unless --quiet was given.
1247
1248 • 1 exit status occurs only when no match was found and no error
1249 occurred.
1250
1251 • 2 exit status occurs when an error occurred. This is true for both
1252 catastrophic errors (e.g., a regex syntax error) and for soft
1253 errors (e.g., unable to read a file).
1254
1256 TL;DR - To disable automatic filtering, use rg -uuu.
1257
1258 One of ripgrep’s most important features is its automatic smart
1259 filtering. It is the most apparent differentiating feature between
1260 ripgrep and other tools like grep. As such, its behavior may be
1261 surprising to users that aren’t expecting it.
1262
1263 ripgrep does four types of filtering automatically:
1264
1265 1. Files and directories that match ignore rules are not searched.
1266
1267 2. Hidden files and directories are not searched.
1268
1269 3. Binary files (files with a NUL byte) are not searched.
1270
1271 4. Symbolic links are not followed.
1272
1273 The first type of filtering is the most sophisticated. ripgrep will
1274 attempt to respect your gitignore rules as faithfully as possible. In
1275 particular, this includes the following:
1276
1277 • Any global rules, e.g., in $HOME/.config/git/ignore.
1278
1279 • Any rules in .gitignore.
1280
1281 • Any local rules, e.g., in .git/info/exclude.
1282
1283 In some cases, ripgrep and git will not always be in sync in terms of
1284 which files are ignored. For example, a file that is ignored via
1285 .gitignore but is tracked by git would not be searched by ripgrep even
1286 though git tracks it. This is unlikely to ever be fixed. Instead, you
1287 should either make sure your exclude rules match the files you track
1288 precisely, or otherwise use git grep for search.
1289
1290 Additional ignore rules can be provided outside of a git context:
1291
1292 • Any rules in .ignore.
1293
1294 • Any rules in .rgignore.
1295
1296 • Any rules in files specified with the --ignore-file flag.
1297
1298 The precedence of ignore rules is as follows, with later items
1299 overriding earlier items:
1300
1301 • Files given by --ignore-file.
1302
1303 • Global gitignore rules, e.g., from $HOME/.config/git/ignore.
1304
1305 • Local rules from .git/info/exclude.
1306
1307 • Rules from .gitignore.
1308
1309 • Rules from .ignore.
1310
1311 • Rules from .rgignore.
1312
1313 So for example, if foo were in a .gitignore and !foo were in an
1314 .rgignore, then foo would not be ignored since .rgignore takes
1315 precedence over .gitignore.
1316
1317 Each of the types of filtering can be configured via command line
1318 flags:
1319
1320 • There are several flags starting with --no-ignore that toggle
1321 which, if any, ignore rules are respected. --no-ignore by itself
1322 will disable all of them.
1323
1324 • --hidden will force ripgrep to search hidden files and directories.
1325
1326 • --binary will force ripgrep to search binary files.
1327
1328 • -L/--follow will force ripgrep to follow symlinks.
1329
1330 As a special short hand, the -u flag can be specified up to three
1331 times. Each additional time incrementally decreases filtering:
1332
1333 • -u is equivalent to --no-ignore.
1334
1335 • -uu is equivalent to --no-ignore --hidden.
1336
1337 • -uuu is equivalent to --no-ignore --hidden --binary.
1338
1339 In particular, rg -uuu should search the same exact content as grep -r.
1340
1342 ripgrep supports reading configuration files that change ripgrep’s
1343 default behavior. The format of the configuration file is an "rc" style
1344 and is very simple. It is defined by two rules:
1345
1346 1. Every line is a shell argument, after trimming whitespace.
1347
1348 2. Lines starting with # (optionally preceded by any amount of
1349 whitespace) are ignored.
1350
1351 ripgrep will look for a single configuration file if and only if the
1352 RIPGREP_CONFIG_PATH environment variable is set and is non-empty.
1353 ripgrep will parse shell arguments from this file on startup and will
1354 behave as if the arguments in this file were prepended to any explicit
1355 arguments given to ripgrep on the command line.
1356
1357 For example, if your ripgreprc file contained a single line:
1358
1359 --smart-case
1360
1361 then the following command
1362
1363 RIPGREP_CONFIG_PATH=wherever/.ripgreprc rg foo
1364
1365 would behave identically to the following command
1366
1367 rg --smart-case foo
1368
1369 another example is adding types
1370
1371 --type-add
1372 web:*.{html,css,js}*
1373
1374 would behave identically to the following command
1375
1376 rg --type-add 'web:*.{html,css,js}*' foo
1377
1378 same with using globs
1379
1380 --glob=!.git
1381
1382 or
1383
1384 --glob
1385 !.git
1386
1387 would behave identically to the following command
1388
1389 rg --glob '!.git' foo
1390
1391 ripgrep also provides a flag, --no-config, that when present will
1392 suppress any and all support for configuration. This includes any
1393 future support for auto-loading configuration files from pre-determined
1394 paths.
1395
1396 Conflicts between configuration files and explicit arguments are
1397 handled exactly like conflicts in the same command line invocation.
1398 That is, this command:
1399
1400 RIPGREP_CONFIG_PATH=wherever/.ripgreprc rg foo --case-sensitive
1401
1402 is exactly equivalent to
1403
1404 rg --smart-case foo --case-sensitive
1405
1406 in which case, the --case-sensitive flag would override the
1407 --smart-case flag.
1408
1410 Shell completion files are included in the release tarball for Bash,
1411 Fish, Zsh and PowerShell.
1412
1413 For bash, move rg.bash to $XDG_CONFIG_HOME/bash_completion or
1414 /etc/bash_completion.d/.
1415
1416 For fish, move rg.fish to $HOME/.config/fish/completions.
1417
1418 For zsh, move _rg to one of your $fpath directories.
1419
1421 ripgrep may abort unexpectedly when using default settings if it
1422 searches a file that is simultaneously truncated. This behavior can be
1423 avoided by passing the --no-mmap flag which will forcefully disable the
1424 use of memory maps in all cases.
1425
1426 ripgrep may use a large amount of memory depending on a few factors.
1427 Firstly, if ripgrep uses parallelism for search (the default), then the
1428 entire output for each individual file is buffered into memory in order
1429 to prevent interleaving matches in the output. To avoid this, you can
1430 disable parallelism with the -j1 flag. Secondly, ripgrep always needs
1431 to have at least a single line in memory in order to execute a search.
1432 A file with a very long line can thus cause ripgrep to use a lot of
1433 memory. Generally, this only occurs when searching binary data with the
1434 -a flag enabled. (When the -a flag isn’t enabled, ripgrep will replace
1435 all NUL bytes with line terminators, which typically prevents
1436 exorbitant memory usage.) Thirdly, when ripgrep searches a large file
1437 using a memory map, the process will report its resident memory usage
1438 as the size of the file. However, this does not mean ripgrep actually
1439 needed to use that much memory; the operating system will generally
1440 handle this for you.
1441
1443 12.1.1
1444
1446 https://github.com/BurntSushi/ripgrep
1447
1448 Please report bugs and feature requests in the issue tracker. Please do
1449 your best to provide a reproducible test case for bugs. This should
1450 include the corpus being searched, the rg command, the actual output
1451 and the expected output. Please also include the output of running the
1452 same rg command but with the --debug flag.
1453
1455 Andrew Gallant jamslam@gmail.com
1456
1457
1458
1459 2021-05-19 RG(1)