1RG(1)                                                                    RG(1)
2
3
4

NAME

6       rg - recursively search the current directory for lines matching a
7       pattern
8

SYNOPSIS

10       rg [OPTIONS] PATTERN [PATH...]
11
12       rg [OPTIONS] -e PATTERN... [PATH...]
13
14       rg [OPTIONS] -f PATTERNFILE... [PATH...]
15
16       rg [OPTIONS] --files [PATH...]
17
18       rg [OPTIONS] --type-list
19
20       command | rg [OPTIONS] PATTERN
21
22       rg [OPTIONS] --help
23
24       rg [OPTIONS] --version
25

DESCRIPTION

27       ripgrep (rg) recursively searches the current directory for a regex
28       pattern. By default, ripgrep will respect your .gitignore and
29       automatically skip hidden files/directories and binary files.
30
31       ripgrep’s default regex engine uses finite automata and guarantees
32       linear time searching. Because of this, features like backreferences
33       and arbitrary look-around are not supported. However, if ripgrep is
34       built with PCRE2, then the --pcre2 flag can be used to enable
35       backreferences and look-around.
36
37       ripgrep supports configuration files. Set RIPGREP_CONFIG_PATH to a
38       configuration file. The file can specify one shell argument per line.
39       Lines starting with # are ignored. For more details, see the man page
40       or the README.
41
42       ripgrep will automatically detect if stdin exists and search stdin for
43       a regex pattern, e.g. ls | rg foo. In some environments, stdin may
44       exist when it shouldn’t. To turn off stdin detection explicitly specify
45       the directory to search, e.g. rg foo ./.
46
47       Tip: to disable all smart filtering and make ripgrep behave a bit more
48       like classical grep, use rg -uuu.
49

REGEX SYNTAX

51       ripgrep uses Rust’s regex engine by default, which documents its
52       syntax: https://docs.rs/regex/*/regex/#syntax
53
54       ripgrep uses byte-oriented regexes, which has some additional
55       documentation: https://docs.rs/regex/*/regex/bytes/index.html#syntax
56
57       To a first approximation, ripgrep uses Perl-like regexes without
58       look-around or backreferences. This makes them very similar to the
59       "extended" (ERE) regular expressions supported by egrep, but with a few
60       additional features like Unicode character classes.
61
62       If you’re using ripgrep with the --pcre2 flag, then please consult
63       https://www.pcre.org or the PCRE2 man pages for documentation on the
64       supported syntax.
65

POSITIONAL ARGUMENTS

67       PATTERN
68           A regular expression used for searching. To match a pattern
69           beginning with a dash, use the -e/--regexp option.
70
71       PATH
72           A file or directory to search. Directories are searched
73           recursively. File paths specified explicitly on the command line
74           override glob and ignore rules.
75

OPTIONS

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

EXIT STATUS

1292       If ripgrep finds a match, then the exit status of the program is 0. If
1293       no match could be found, then the exit status is 1. If an error
1294       occurred, then the exit status is always 2 unless ripgrep was run with
1295       the --quiet flag and a match was found. In summary:
1296
1297       •   0 exit status occurs only when at least one match was found, and if
1298           no error occurred, unless --quiet was given.
1299
1300       •   1 exit status occurs only when no match was found and no error
1301           occurred.
1302
1303       •   2 exit status occurs when an error occurred. This is true for both
1304           catastrophic errors (e.g., a regex syntax error) and for soft
1305           errors (e.g., unable to read a file).
1306

AUTOMATIC FILTERING

1308       TL;DR - To disable automatic filtering, use rg -uuu.
1309
1310       One of ripgrep’s most important features is its automatic smart
1311       filtering. It is the most apparent differentiating feature between
1312       ripgrep and other tools like grep. As such, its behavior may be
1313       surprising to users that aren’t expecting it.
1314
1315       ripgrep does four types of filtering automatically:
1316
1317        1. Files and directories that match ignore rules are not searched.
1318
1319        2. Hidden files and directories are not searched.
1320
1321        3. Binary files (files with a NUL byte) are not searched.
1322
1323        4. Symbolic links are not followed.
1324
1325       The first type of filtering is the most sophisticated. ripgrep will
1326       attempt to respect your gitignore rules as faithfully as possible. In
1327       particular, this includes the following:
1328
1329       •   Any global rules, e.g., in $HOME/.config/git/ignore.
1330
1331       •   Any rules in .gitignore.
1332
1333       •   Any local rules, e.g., in .git/info/exclude.
1334
1335       In some cases, ripgrep and git will not always be in sync in terms of
1336       which files are ignored. For example, a file that is ignored via
1337       .gitignore but is tracked by git would not be searched by ripgrep even
1338       though git tracks it. This is unlikely to ever be fixed. Instead, you
1339       should either make sure your exclude rules match the files you track
1340       precisely, or otherwise use git grep for search.
1341
1342       Additional ignore rules can be provided outside of a git context:
1343
1344       •   Any rules in .ignore.
1345
1346       •   Any rules in .rgignore.
1347
1348       •   Any rules in files specified with the --ignore-file flag.
1349
1350       The precedence of ignore rules is as follows, with later items
1351       overriding earlier items:
1352
1353       •   Files given by --ignore-file.
1354
1355       •   Global gitignore rules, e.g., from $HOME/.config/git/ignore.
1356
1357       •   Local rules from .git/info/exclude.
1358
1359       •   Rules from .gitignore.
1360
1361       •   Rules from .ignore.
1362
1363       •   Rules from .rgignore.
1364
1365       So for example, if foo were in a .gitignore and !foo were in an
1366       .rgignore, then foo would not be ignored since .rgignore takes
1367       precedence over .gitignore.
1368
1369       Each of the types of filtering can be configured via command line
1370       flags:
1371
1372       •   There are several flags starting with --no-ignore that toggle
1373           which, if any, ignore rules are respected. --no-ignore by itself
1374           will disable all of them.
1375
1376-./--hidden will force ripgrep to search hidden files and
1377           directories.
1378
1379--binary will force ripgrep to search binary files.
1380
1381-L/--follow will force ripgrep to follow symlinks.
1382
1383       As a special short hand, the -u flag can be specified up to three
1384       times. Each additional time incrementally decreases filtering:
1385
1386-u is equivalent to --no-ignore.
1387
1388-uu is equivalent to --no-ignore --hidden.
1389
1390-uuu is equivalent to --no-ignore --hidden --binary.
1391
1392       In particular, rg -uuu should search the same exact content as grep -r.
1393

CONFIGURATION FILES

1395       ripgrep supports reading configuration files that change ripgrep’s
1396       default behavior. The format of the configuration file is an "rc" style
1397       and is very simple. It is defined by two rules:
1398
1399        1. Every line is a shell argument, after trimming whitespace.
1400
1401        2. Lines starting with # (optionally preceded by any amount of
1402           whitespace) are ignored.
1403
1404       ripgrep will look for a single configuration file if and only if the
1405       RIPGREP_CONFIG_PATH environment variable is set and is non-empty.
1406       ripgrep will parse shell arguments from this file on startup and will
1407       behave as if the arguments in this file were prepended to any explicit
1408       arguments given to ripgrep on the command line. Note though that the rg
1409       command you run must still be valid. That is, it must always contain at
1410       least one pattern at the command line, even if the configuration file
1411       uses the -e/--regexp flag.
1412
1413       For example, if your ripgreprc file contained a single line:
1414
1415           --smart-case
1416
1417       then the following command
1418
1419           RIPGREP_CONFIG_PATH=wherever/.ripgreprc rg foo
1420
1421       would behave identically to the following command
1422
1423           rg --smart-case foo
1424
1425       another example is adding types
1426
1427           --type-add
1428           web:*.{html,css,js}*
1429
1430       would behave identically to the following command
1431
1432           rg --type-add 'web:*.{html,css,js}*' foo
1433
1434       same with using globs
1435
1436           --glob=!.git
1437
1438       or
1439
1440           --glob
1441           !.git
1442
1443       would behave identically to the following command
1444
1445           rg --glob '!.git' foo
1446
1447       ripgrep also provides a flag, --no-config, that when present will
1448       suppress any and all support for configuration. This includes any
1449       future support for auto-loading configuration files from pre-determined
1450       paths.
1451
1452       Conflicts between configuration files and explicit arguments are
1453       handled exactly like conflicts in the same command line invocation.
1454       That is, this command:
1455
1456           RIPGREP_CONFIG_PATH=wherever/.ripgreprc rg foo --case-sensitive
1457
1458       is exactly equivalent to
1459
1460           rg --smart-case foo --case-sensitive
1461
1462       in which case, the --case-sensitive flag would override the
1463       --smart-case flag.
1464

SHELL COMPLETION

1466       Shell completion files are included in the release tarball for Bash,
1467       Fish, Zsh and PowerShell.
1468
1469       For bash, move rg.bash to $XDG_CONFIG_HOME/bash_completion or
1470       /etc/bash_completion.d/.
1471
1472       For fish, move rg.fish to $HOME/.config/fish/completions.
1473
1474       For zsh, move _rg to one of your $fpath directories.
1475

CAVEATS

1477       ripgrep may abort unexpectedly when using default settings if it
1478       searches a file that is simultaneously truncated. This behavior can be
1479       avoided by passing the --no-mmap flag which will forcefully disable the
1480       use of memory maps in all cases.
1481
1482       ripgrep may use a large amount of memory depending on a few factors.
1483       Firstly, if ripgrep uses parallelism for search (the default), then the
1484       entire output for each individual file is buffered into memory in order
1485       to prevent interleaving matches in the output. To avoid this, you can
1486       disable parallelism with the -j1 flag. Secondly, ripgrep always needs
1487       to have at least a single line in memory in order to execute a search.
1488       A file with a very long line can thus cause ripgrep to use a lot of
1489       memory. Generally, this only occurs when searching binary data with the
1490       -a flag enabled. (When the -a flag isn’t enabled, ripgrep will replace
1491       all NUL bytes with line terminators, which typically prevents
1492       exorbitant memory usage.) Thirdly, when ripgrep searches a large file
1493       using a memory map, the process will report its resident memory usage
1494       as the size of the file. However, this does not mean ripgrep actually
1495       needed to use that much memory; the operating system will generally
1496       handle this for you.
1497

VERSION

1499       13.0.0
1500

HOMEPAGE

1502       https://github.com/BurntSushi/ripgrep
1503
1504       Please report bugs and feature requests in the issue tracker. Please do
1505       your best to provide a reproducible test case for bugs. This should
1506       include the corpus being searched, the rg command, the actual output
1507       and the expected output. Please also include the output of running the
1508       same rg command but with the --debug flag.
1509

AUTHORS

1511       Andrew Gallant jamslam@gmail.com
1512
1513
1514
1515                                  2021-07-27                             RG(1)
Impressum