.TH RG 1 2023-11-26 "14.1.0" "User Commands" . . .SH NAME rg \- recursively search the current directory for lines matching a pattern . . .SH SYNOPSIS .\" I considered using GNU troff's .SY and .YS "synopsis" macros here, but it .\" looks like they aren't portable. Specifically, they don't appear to be in .\" BSD's mdoc used on macOS. .sp \fBrg\fP [\fIOPTIONS\fP] \fIPATTERN\fP [\fIPATH\fP...] .sp \fBrg\fP [\fIOPTIONS\fP] \fB\-e\fP \fIPATTERN\fP... [\fIPATH\fP...] .sp \fBrg\fP [\fIOPTIONS\fP] \fB\-f\fP \fIPATTERNFILE\fP... [\fIPATH\fP...] .sp \fBrg\fP [\fIOPTIONS\fP] \fB\-\-files\fP [\fIPATH\fP...] .sp \fBrg\fP [\fIOPTIONS\fP] \fB\-\-type\-list\fP .sp \fIcommand\fP | \fBrg\fP [\fIOPTIONS\fP] \fIPATTERN\fP .sp \fBrg\fP [\fIOPTIONS\fP] \fB\-\-help\fP .sp \fBrg\fP [\fIOPTIONS\fP] \fB\-\-version\fP . . .SH DESCRIPTION ripgrep (rg) recursively searches the current directory for a regex pattern. By default, ripgrep will respect your \fB.gitignore\fP and automatically skip hidden files/directories and binary files. .sp ripgrep's default regex engine uses finite automata and guarantees linear time searching. Because of this, features like backreferences and arbitrary look-around are not supported. However, if ripgrep is built with PCRE2, then the \fB\-P/\-\-pcre2\fP flag can be used to enable backreferences and look-around. .sp ripgrep supports configuration files. Set \fBRIPGREP_CONFIG_PATH\fP to a configuration file. The file can specify one shell argument per line. Lines starting with \fB#\fP are ignored. For more details, see \fBCONFIGURATION FILES\fP below. .sp ripgrep will automatically detect if stdin exists and search stdin for a regex pattern, e.g. \fBls | rg foo\fP. In some environments, stdin may exist when it shouldn't. To turn off stdin detection, one can explicitly specify the directory to search, e.g. \fBrg foo ./\fP. .sp Like other tools such as \fBls\fP, ripgrep will alter its output depending on whether stdout is connected to a tty. By default, when printing a tty, ripgrep will enable colors, line numbers and a heading format that lists each matching file path once instead of once per matching line. .sp Tip: to disable all smart filtering and make ripgrep behave a bit more like classical grep, use \fBrg -uuu\fP. . . .SH REGEX SYNTAX ripgrep uses Rust's regex engine by default, which documents its syntax: \fIhttps://docs.rs/regex/1.*/regex/#syntax\fP .sp ripgrep uses byte-oriented regexes, which has some additional documentation: \fIhttps://docs.rs/regex/1.*/regex/bytes/index.html#syntax\fP .sp To a first approximation, ripgrep uses Perl-like regexes without look-around or backreferences. This makes them very similar to the "extended" (ERE) regular expressions supported by *egrep*, but with a few additional features like Unicode character classes. .sp If you're using ripgrep with the \fB\-P/\-\-pcre2\fP flag, then please consult \fIhttps://www.pcre.org\fP or the PCRE2 man pages for documentation on the supported syntax. . . .SH POSITIONAL ARGUMENTS .TP 12 \fIPATTERN\fP A regular expression used for searching. To match a pattern beginning with a dash, use the \fB\-e/\-\-regexp\fP option. .TP 12 \fIPATH\fP A file or directory to search. Directories are searched recursively. File paths specified explicitly on the command line override glob and ignore rules. . . .SH OPTIONS This section documents all flags that ripgrep accepts. Flags are grouped into categories below according to their function. .sp Note that many options can be turned on and off. In some cases, those flags are not listed explicitly below. For example, the \fB\-\-column\fP flag (listed below) enables column numbers in ripgrep's output, but the \fB\-\-no\-column\fP flag (not listed below) disables them. The reverse can also exist. For example, the \fB\-\-no\-ignore\fP flag (listed below) disables ripgrep's \fBgitignore\fP logic, but the \fB\-\-ignore\fP flag (not listed below) enables it. These flags are useful for overriding a ripgrep configuration file (or alias) on the command line. Each flag's documentation notes whether an inverted flag exists. In all cases, the flag specified last takes precedence. . .SS INPUT OPTIONS \fB\-e\fP \fIPATTERN\fP, \fB\-\-regexp\fP=\fIPATTERN\fP .RS 4 A pattern to search for. This option can be provided multiple times, where all patterns given are searched, in addition to any patterns provided by \fB\-f/\-\-file\fP. Lines matching at least one of the provided patterns are printed. This flag can also be used when searching for patterns that start with a dash. .sp For example, to search for the literal \fB\-foo\fP: .sp .EX rg \-e \-foo .EE .sp You can also use the special \fB\-\-\fP delimiter to indicate that no more flags will be provided. Namely, the following is equivalent to the above: .sp .EX rg \-\- \-foo .EE .sp When \fB\-f/\-\-file\fP or \fB\-e/\-\-regexp\fP is used, then ripgrep treats all positional arguments as files or directories to search. .RE .sp \fB\-f\fP \fIPATTERNFILE\fP, \fB\-\-file\fP=\fIPATTERNFILE\fP .RS 4 Search for patterns from the given file, with one pattern per line. When this flag is used multiple times or in combination with the \fB\-e/\-\-regexp\fP flag, then all patterns provided are searched. Empty pattern lines will match all input lines, and the newline is not counted as part of the pattern. .sp A line is printed if and only if it matches at least one of the patterns. .sp When \fIPATTERNFILE\fP is \fB-\fP, then \fBstdin\fP will be read for the patterns. .sp When \fB\-f/\-\-file\fP or \fB\-e/\-\-regexp\fP is used, then ripgrep treats all positional arguments as files or directories to search. .RE .sp \fB\-\-pre\fP=\fICOMMAND\fP .RS 4 For each input \fIPATH\fP, this flag causes ripgrep to search the standard output of \fICOMMAND\fP \fIPATH\fP instead of the contents of \fIPATH\fP. This option expects the \fICOMMAND\fP program to either be a path or to be available in your \fBPATH\fP. Either an empty string \fICOMMAND\fP or the \fB\-\-no\-pre\fP flag will disable this behavior. .sp .TP 12 \fBWARNING\fP When this flag is set, ripgrep will unconditionally spawn a process for every file that is searched. Therefore, this can incur an unnecessarily large performance penalty if you don't otherwise need the flexibility offered by this flag. One possible mitigation to this is to use the \fB\-\-pre-glob\fP flag to limit which files a preprocessor is run with. .PP A preprocessor is not run when ripgrep is searching stdin. .sp When searching over sets of files that may require one of several preprocessors, \fICOMMAND\fP should be a wrapper program which first classifies \fIPATH\fP based on magic numbers/content or based on the \fIPATH\fP name and then dispatches to an appropriate preprocessor. Each \fICOMMAND\fP also has its standard input connected to \fIPATH\fP for convenience. .sp For example, a shell script for \fICOMMAND\fP might look like: .sp .EX case "$1" in *.pdf) exec pdftotext "$1" - ;; *) case $(file "$1") in *Zstandard*) exec pzstd -cdq ;; *) exec cat ;; esac ;; esac .EE .sp The above script uses \fBpdftotext\fP to convert a PDF file to plain text. For all other files, the script uses the \fBfile\fP utility to sniff the type of the file based on its contents. If it is a compressed file in the Zstandard format, then \fBpzstd\fP is used to decompress the contents to stdout. .sp This overrides the \fB\-z/\-\-search-zip\fP flag. .RE .sp \fB\-\-pre-glob\fP=\fIGLOB\fP .RS 4 This flag works in conjunction with the \fB\-\-pre\fP flag. Namely, when one or more \fB\-\-pre-glob\fP flags are given, then only files that match the given set of globs will be handed to the command specified by the \fB\-\-pre\fP flag. Any non-matching files will be searched without using the preprocessor command. .sp This flag is useful when searching many files with the \fB\-\-pre\fP flag. Namely, it provides the ability to avoid process overhead for files that don't need preprocessing. For example, given the following shell script, \fIpre-pdftotext\fP: .sp .EX #!/bin/sh pdftotext "$1" - .EE .sp then it is possible to use \fB\-\-pre\fP \fIpre-pdftotext\fP \fB--pre-glob '\fP\fI*.pdf\fP\fB'\fP to make it so ripgrep only executes the \fIpre-pdftotext\fP command on files with a \fI.pdf\fP extension. .sp Multiple \fB\-\-pre-glob\fP flags may be used. Globbing rules match \fBgitignore\fP globs. Precede a glob with a \fB!\fP to exclude it. .sp This flag has no effect if the \fB\-\-pre\fP flag is not used. .RE .sp \fB\-z\fP, \fB\-\-search-zip\fP .RS 4 This flag instructs ripgrep to search in compressed files. Currently gzip, bzip2, xz, LZ4, LZMA, Brotli and Zstd files are supported. This option expects the decompression binaries (such as \fBgzip\fP) to be available in your \fBPATH\fP. If the required binaries are not found, then ripgrep will not emit an error messages by default. Use the \fB\-\-debug\fP flag to see more information. .sp Note that this flag does not make ripgrep search archive formats as directory trees. It only makes ripgrep detect compressed files and then decompress them before searching their contents as it would any other file. .sp This overrides the \fB\-\-pre\fP flag. .sp This flag can be disabled with \fB\-\-no-search-zip\fP. .RE . .SS SEARCH OPTIONS \fB\-s\fP, \fB\-\-case-sensitive\fP .RS 4 Execute the search case sensitively. This is the default mode. .sp This is a global option that applies to all patterns given to ripgrep. Individual patterns can still be matched case insensitively by using inline regex flags. For example, \fB(?i)abc\fP will match \fBabc\fP case insensitively even when this flag is used. .sp This flag overrides the \fB\-i/\-\-ignore-case\fP and \fB\-S/\-\-smart-case\fP flags. .RE .sp \fB\-\-crlf\fP .RS 4 When enabled, ripgrep will treat CRLF (\fB\\r\\n\fP) as a line terminator instead of just \fB\\n\fP. .sp Principally, this permits the line anchor assertions \fB^\fP and \fB$\fP in regex patterns to treat CRLF, CR or LF as line terminators instead of just LF. Note that they will never match between a CR and a LF. CRLF is treated as one single line terminator. .sp When using the default regex engine, CRLF support can also be enabled inside the pattern with the \fBR\fP flag. For example, \fB(?R:$)\fP will match just before either CR or LF, but never between CR and LF. .sp This flag overrides \fB\-\-null-data\fP. .sp This flag can be disabled with \fB\-\-no-crlf\fP. .RE .sp \fB\-\-dfa-size-limit\fP=\fINUM+SUFFIX?\fP .RS 4 The upper size limit of the regex DFA. The default limit is something generous for any single pattern or for many smallish patterns. This should only be changed on very large regex inputs where the (slower) fallback regex engine may otherwise be used if the limit is reached. .sp The input format accepts suffixes of \fBK\fP, \fBM\fP or \fBG\fP which correspond to kilobytes, megabytes and gigabytes, respectively. If no suffix is provided the input is treated as bytes. .RE .sp \fB\-E\fP \fIENCODING\fP, \fB\-\-encoding\fP=\fIENCODING\fP .RS 4 Specify the text encoding that ripgrep will use on all files searched. The default value is \fBauto\fP, which will cause ripgrep to do a best effort automatic detection of encoding on a per-file basis. Automatic detection in this case only applies to files that begin with a UTF-8 or UTF-16 byte-order mark (BOM). No other automatic detection is performed. One can also specify \fBnone\fP which will then completely disable BOM sniffing and always result in searching the raw bytes, including a BOM if it's present, regardless of its encoding. .sp Other supported values can be found in the list of labels here: \fIhttps://encoding.spec.whatwg.org/#concept-encoding-get\fP. .sp For more details on encoding and how ripgrep deals with it, see \fBGUIDE.md\fP. .sp The encoding detection that ripgrep uses can be reverted to its automatic mode via the \fB\-\-no-encoding\fP flag. .RE .sp \fB\-\-engine\fP=\fIENGINE\fP .RS 4 Specify which regular expression engine to use. When you choose a regex engine, it applies that choice for every regex provided to ripgrep (e.g., via multiple \fB\-e/\-\-regexp\fP or \fB\-f/\-\-file\fP flags). .sp Accepted values are \fBdefault\fP, \fBpcre2\fP, or \fBauto\fP. .sp The default value is \fBdefault\fP, which is usually the fastest and should be good for most use cases. The \fBpcre2\fP engine is generally useful when you want to use features such as look-around or backreferences. \fBauto\fP will dynamically choose between supported regex engines depending on the features used in a pattern on a best effort basis. .sp Note that the \fBpcre2\fP engine is an optional ripgrep feature. If PCRE2 wasn't included in your build of ripgrep, then using this flag will result in ripgrep printing an error message and exiting. .sp This overrides previous uses of the \fB\-P/\-\-pcre2\fP and \fB\-\-auto-hybrid-regex\fP flags. .RE .sp \fB\-F\fP, \fB\-\-fixed-strings\fP .RS 4 Treat all patterns as literals instead of as regular expressions. When this flag is used, special regular expression meta characters such as \fB.(){}*+\fP should not need be escaped. .sp This flag can be disabled with \fB\-\-no-fixed-strings\fP. .RE .sp \fB\-i\fP, \fB\-\-ignore-case\fP .RS 4 When this flag is provided, all patterns will be searched case insensitively. The case insensitivity rules used by ripgrep's default regex engine conform to Unicode's "simple" case folding rules. .sp This is a global option that applies to all patterns given to ripgrep. Individual patterns can still be matched case sensitively by using inline regex flags. For example, \fB(?\-i)abc\fP will match \fBabc\fP case sensitively even when this flag is used. .sp This flag overrides \fB\-s/\-\-case-sensitive\fP and \fB\-S/\-\-smart-case\fP. .RE .sp \fB\-v\fP, \fB\-\-invert-match\fP .RS 4 This flag inverts matching. That is, instead of printing lines that match, ripgrep will print lines that don't match. .sp Note that this only inverts line-by-line matching. For example, combining this flag with \fB\-l/\-\-files-with-matches\fP will emit files that contain any lines that do not match the patterns given. That's not the same as, for example, \fB\-\-files-without-match\fP, which will emit files that do not contain any matching lines. .sp This flag can be disabled with \fB\-\-no-invert-match\fP. .RE .sp \fB\-x\fP, \fB\-\-line-regexp\fP .RS 4 When enabled, ripgrep will only show matches surrounded by line boundaries. This is equivalent to surrounding every pattern with \fB^\fP and \fB$\fP. In other words, this only prints lines where the entire line participates in a match. .sp This overrides the \fB\-w/\-\-word-regexp\fP flag. .RE .sp \fB\-m\fP \fINUM\fP, \fB\-\-max-count\fP=\fINUM\fP .RS 4 Limit the number of matching lines per file searched to \fINUM\fP. .sp Note that \fB0\fP is a legal value but not likely to be useful. When used, ripgrep won't search anything. .RE .sp \fB\-\-mmap\fP .RS 4 When enabled, ripgrep will search using memory maps when possible. This is enabled by default when ripgrep thinks it will be faster. .sp Memory map searching cannot be used in all circumstances. For example, when searching virtual files or streams likes \fBstdin\fP. In such cases, memory maps will not be used even when this flag is enabled. .sp Note that ripgrep may abort unexpectedly when memory maps are used if it searches a file that is simultaneously truncated. Users can opt out of this possibility by disabling memory maps. .sp This flag can be disabled with \fB\-\-no-mmap\fP. .RE .sp \fB\-U\fP, \fB\-\-multiline\fP .RS 4 This flag enable searching across multiple lines. .sp When multiline mode is enabled, ripgrep will lift the restriction that a match cannot include a line terminator. For example, when multiline mode is not enabled (the default), then the regex \fB\\p{any}\fP will match any Unicode codepoint other than \fB\\n\fP. Similarly, the regex \fB\\n\fP is explicitly forbidden, and if you try to use it, ripgrep will return an error. However, when multiline mode is enabled, \fB\\p{any}\fP will match any Unicode codepoint, including \fB\\n\fP, and regexes like \fB\\n\fP are permitted. .sp An important caveat is that multiline mode does not change the match semantics of \fB.\fP. Namely, in most regex matchers, a \fB.\fP will by default match any character other than \fB\\n\fP, and this is true in ripgrep as well. In order to make \fB.\fP match \fB\\n\fP, you must enable the "dot all" flag inside the regex. For example, both \fB(?s).\fP and \fB(?s:.)\fP have the same semantics, where \fB.\fP will match any character, including \fB\\n\fP. Alternatively, the \fB\-\-multiline-dotall\fP flag may be passed to make the "dot all" behavior the default. This flag only applies when multiline search is enabled. .sp There is no limit on the number of the lines that a single match can span. .sp \fBWARNING\fP: Because of how the underlying regex engine works, multiline searches may be slower than normal line-oriented searches, and they may also use more memory. In particular, when multiline mode is enabled, ripgrep requires that each file it searches is laid out contiguously in memory (either by reading it onto the heap or by memory-mapping it). Things that cannot be memory-mapped (such as \fBstdin\fP) will be consumed until EOF before searching can begin. In general, ripgrep will only do these things when necessary. Specifically, if the \fB\-U/\-\-multiline\fP flag is provided but the regex does not contain patterns that would match \fB\\n\fP characters, then ripgrep will automatically avoid reading each file into memory before searching it. Nevertheless, if you only care about matches spanning at most one line, then it is always better to disable multiline mode. .sp This overrides the \fB\-\-stop-on-nonmatch\fP flag. .sp This flag can be disabled with \fB\-\-no-multiline\fP. .RE .sp \fB\-\-multiline-dotall\fP .RS 4 This flag enables "dot all" mode in all regex patterns. This causes \fB.\fP to match line terminators when multiline searching is enabled. This flag has no effect if multiline searching isn't enabled with the \fB\-U/\-\-multiline\fP flag. .sp Normally, a \fB.\fP will match any character except line terminators. While this behavior typically isn't relevant for line-oriented matching (since matches can span at most one line), this can be useful when searching with the \fB\-U/\-\-multiline\fP flag. By default, multiline mode runs without "dot all" mode enabled. .sp This flag is generally intended to be used in an alias or your ripgrep config file if you prefer "dot all" semantics by default. Note that regardless of whether this flag is used, "dot all" semantics can still be controlled via inline flags in the regex pattern itself, e.g., \fB(?s:.)\fP always enables "dot all" whereas \fB(?-s:.)\fP always disables "dot all". Moreover, you can use character classes like \fB\\p{any}\fP to match any Unicode codepoint regardless of whether "dot all" mode is enabled or not. .sp This flag can be disabled with \fB\-\-no-multiline-dotall\fP. .RE .sp \fB\-\-no-unicode\fP .RS 4 This flag disables Unicode mode for all patterns given to ripgrep. .sp By default, ripgrep will enable "Unicode mode" in all of its regexes. This has a number of consequences: .sp .IP \(bu 3n \fB.\fP will only match valid UTF-8 encoded Unicode scalar values. .sp .IP \(bu 3n Classes like \fB\\w\fP, \fB\\s\fP, \fB\\d\fP are all Unicode aware and much bigger than their ASCII only versions. .sp .IP \(bu 3n Case insensitive matching will use Unicode case folding. .sp .IP \(bu 3n A large array of classes like \fB\\p{Emoji}\fP are available. (Although the specific set of classes available varies based on the regex engine. In general, the default regex engine has more classes available to it.) .sp .IP \(bu 3n Word boundaries (\fB\\b\fP and \fB\\B\fP) use the Unicode definition of a word character. .PP In some cases it can be desirable to turn these things off. This flag will do exactly that. For example, Unicode mode can sometimes have a negative impact on performance, especially when things like \fB\\w\fP are used frequently (including via bounded repetitions like \fB\\w{100}\fP) when only their ASCII interpretation is needed. .sp This flag can be disabled with \fB\-\-unicode\fP. .RE .sp \fB\-\-null-data\fP .RS 4 Enabling this flag causes ripgrep to use \fBNUL\fP as a line terminator instead of the default of \fP\\n\fP. .sp This is useful when searching large binary files that would otherwise have very long lines if \fB\\n\fP were used as the line terminator. In particular, ripgrep requires that, at a minimum, each line must fit into memory. Using \fBNUL\fP instead can be a useful stopgap to keep memory requirements low and avoid OOM (out of memory) conditions. .sp This is also useful for processing NUL delimited data, such as that emitted when using ripgrep's \fB\-0/\-\-null\fP flag or \fBfind\fP's \fB\-\-print0\fP flag. .sp Using this flag implies \fB\-a/\-\-text\fP. It also overrides \fB\-\-crlf\fP. .RE .sp \fB\-P\fP, \fB\-\-pcre2\fP .RS 4 When this flag is present, ripgrep will use the PCRE2 regex engine instead of its default regex engine. .sp This is generally useful when you want to use features such as look-around or backreferences. .sp Using this flag is the same as passing \fB\-\-engine=pcre2\fP. Users may instead elect to use \fB\-\-engine=auto\fP to ask ripgrep to automatically select the right regex engine based on the patterns given. This flag and the \fB\-\-engine\fP flag override one another. .sp Note that PCRE2 is an optional ripgrep feature. If PCRE2 wasn't included in your build of ripgrep, then using this flag will result in ripgrep printing an error message and exiting. PCRE2 may also have worse user experience in some cases, since it has fewer introspection APIs than ripgrep's default regex engine. For example, if you use a \fB\\n\fP in a PCRE2 regex without the \fB\-U/\-\-multiline\fP flag, then ripgrep will silently fail to match anything instead of reporting an error immediately (like it does with the default regex engine). .sp This flag can be disabled with \fB\-\-no-pcre2\fP. .RE .sp \fB\-\-regex-size-limit\fP=\fINUM+SUFFIX?\fP .RS 4 The size limit of the compiled regex, where the compiled regex generally corresponds to a single object in memory that can match all of the patterns provided to ripgrep. The default limit is generous enough that most reasonable patterns (or even a small number of them) should fit. .sp This useful to change when you explicitly want to let ripgrep spend potentially much more time and/or memory building a regex matcher. .sp The input format accepts suffixes of \fBK\fP, \fBM\fP or \fBG\fP which correspond to kilobytes, megabytes and gigabytes, respectively. If no suffix is provided the input is treated as bytes. .RE .sp \fB\-S\fP, \fB\-\-smart-case\fP .RS 4 This flag instructs ripgrep to searches case insensitively if the pattern is all lowercase. Otherwise, ripgrep will search case sensitively. .sp A pattern is considered all lowercase if both of the following rules hold: .sp .IP \(bu 3n First, the pattern contains at least one literal character. For example, \fBa\\w\fP contains a literal (\fBa\fP) but just \fB\\w\fP does not. .sp .IP \(bu 3n Second, of the literals in the pattern, none of them are considered to be uppercase according to Unicode. For example, \fBfoo\\pL\fP has no uppercase literals but \fBFoo\\pL\fP does. .PP This overrides the \fB\-s/\-\-case-sensitive\fP and \fB\-i/\-\-ignore-case\fP flags. .RE .sp \fB\-\-stop-on-nonmatch\fP .RS 4 Enabling this option will cause ripgrep to stop reading a file once it encounters a non-matching line after it has encountered a matching line. This is useful if it is expected that all matches in a given file will be on sequential lines, for example due to the lines being sorted. .sp This overrides the \fB\-U/\-\-multiline\fP flag. .RE .sp \fB\-a\fP, \fB\-\-text\fP .RS 4 This flag instructs ripgrep to search binary files as if they were text. When this flag is present, ripgrep's binary file detection is disabled. This means that when a binary file is searched, its contents may be printed if there is a match. This may cause escape codes to be printed that alter the behavior of your terminal. .sp When binary file detection is enabled, it is imperfect. In general, it uses a simple heuristic. If a \fBNUL\fP byte is seen during search, then the file is considered binary and searching stops (unless this flag is present). Alternatively, if the \fB\-\-binary\fP flag is used, then ripgrep will only quit when it sees a \fBNUL\fP byte after it sees a match (or searches the entire file). .sp This flag overrides the \fB\-\-binary\fP flag. .sp This flag can be disabled with \fB\-\-no-text\fP. .RE .sp \fB\-j\fP \fINUM\fP, \fB\-\-threads\fP=\fINUM\fP .RS 4 This flag sets the approximate number of threads to use. A value of \fB0\fP (which is the default) causes ripgrep to choose the thread count using heuristics. .RE .sp \fB\-w\fP, \fB\-\-word-regexp\fP .RS 4 When enabled, ripgrep will only show matches surrounded by word boundaries. This is equivalent to surrounding every pattern with \fB\\b{start-half}\fP and \fB\\b{end-half}\fP. .sp This overrides the \fB\-x/\-\-line-regexp\fP flag. .RE .sp \fB\-\-auto-hybrid-regex\fP .RS 4 DEPRECATED. Use \fB\-\-engine\fP instead. .sp When this flag is used, ripgrep will dynamically choose between supported regex engines depending on the features used in a pattern. When ripgrep chooses a regex engine, it applies that choice for every regex provided to ripgrep (e.g., via multiple \fB\-e/\-\-regexp\fP or \fB\-f/\-\-file\fP flags). .sp As an example of how this flag might behave, ripgrep will attempt to use its default finite automata based regex engine whenever the pattern can be successfully compiled with that regex engine. If PCRE2 is enabled and if the pattern given could not be compiled with the default regex engine, then PCRE2 will be automatically used for searching. If PCRE2 isn't available, then this flag has no effect because there is only one regex engine to choose from. .sp In the future, ripgrep may adjust its heuristics for how it decides which regex engine to use. In general, the heuristics will be limited to a static analysis of the patterns, and not to any specific runtime behavior observed while searching files. .sp The primary downside of using this flag is that it may not always be obvious which regex engine ripgrep uses, and thus, the match semantics or performance profile of ripgrep may subtly and unexpectedly change. However, in many cases, all regex engines will agree on what constitutes a match and it can be nice to transparently support more advanced regex features like look-around and backreferences without explicitly needing to enable them. .sp This flag can be disabled with \fB\-\-no-auto-hybrid-regex\fP. .RE .sp \fB\-\-no-pcre2-unicode\fP .RS 4 DEPRECATED. Use \fB\-\-no-unicode\fP instead. .sp Note that Unicode mode is enabled by default. .sp This flag can be disabled with \fB\-\-pcre2-unicode\fP. .RE . .SS FILTER OPTIONS \fB\-\-binary\fP .RS 4 Enabling this flag will cause ripgrep to search binary files. By default, ripgrep attempts to automatically skip binary files in order to improve the relevance of results and make the search faster. .sp Binary files are heuristically detected based on whether they contain a \fBNUL\fP byte or not. By default (without this flag set), once a \fBNUL\fP byte is seen, ripgrep will stop searching the file. Usually, \fBNUL\fP bytes occur in the beginning of most binary files. If a \fBNUL\fP byte occurs after a match, then ripgrep will not print the match, stop searching that file, and emit a warning that some matches are being suppressed. .sp In contrast, when this flag is provided, ripgrep will continue searching a file even if a \fBNUL\fP byte is found. In particular, if a \fBNUL\fP byte is found then ripgrep will continue searching until either a match is found or the end of the file is reached, whichever comes sooner. If a match is found, then ripgrep will stop and print a warning saying that the search stopped prematurely. .sp If you want ripgrep to search a file without any special \fBNUL\fP byte handling at all (and potentially print binary data to stdout), then you should use the \fB\-a/\-\-text\fP flag. .sp The \fB\-\-binary\fP flag is a flag for controlling ripgrep's automatic filtering mechanism. As such, it does not need to be used when searching a file explicitly or when searching stdin. That is, it is only applicable when recursively searching a directory. .sp When the \fB\-u/\-\-unrestricted\fP flag is provided for a third time, then this flag is automatically enabled. .sp This flag overrides the \fB\-a/\-\-text\fP flag. .sp This flag can be disabled with \fB\-\-no-binary\fP. .RE .sp \fB\-L\fP, \fB\-\-follow\fP .RS 4 This flag instructs ripgrep to follow symbolic links while traversing directories. This behavior is disabled by default. Note that ripgrep will check for symbolic link loops and report errors if it finds one. ripgrep will also report errors for broken links. To suppress error messages, use the \fB\-\-no-messages\fP flag. .sp This flag can be disabled with \fB\-\-no-follow\fP. .RE .sp \fB\-g\fP \fIGLOB\fP, \fB\-\-glob\fP=\fIGLOB\fP .RS 4 Include or exclude files and directories for searching that match the given glob. This always overrides any other ignore logic. Multiple glob flags may be used. Globbing rules match \fB.gitignore\fP globs. Precede a glob with a \fB!\fP to exclude it. If multiple globs match a file or directory, the glob given later in the command line takes precedence. .sp As an extension, globs support specifying alternatives: .BI "\-g '" ab{c,d}* ' is equivalent to .BI "\-g " "abc " "\-g " abd. Empty alternatives like .BI "\-g '" ab{,c} ' are not currently supported. Note that this syntax extension is also currently enabled in \fBgitignore\fP files, even though this syntax isn't supported by git itself. ripgrep may disable this syntax extension in gitignore files, but it will always remain available via the \fB\-g/\-\-glob\fP flag. .sp When this flag is set, every file and directory is applied to it to test for a match. For example, if you only want to search in a particular directory \fIfoo\fP, then .BI "\-g " foo is incorrect because \fIfoo/bar\fP does not match the glob \fIfoo\fP. Instead, you should use .BI "\-g '" foo/** '. .RE .sp \fB\-\-glob-case-insensitive\fP .RS 4 Process all glob patterns given with the \fB\-g/\-\-glob\fP flag case insensitively. This effectively treats \fB\-g/\-\-glob\fP as \fB\-\-iglob\fP. .sp This flag can be disabled with \fB\-\-no-glob-case-insensitive\fP. .RE .sp \fB\-.\fP, \fB\-\-hidden\fP .RS 4 Search hidden files and directories. By default, hidden files and directories are skipped. Note that if a hidden file or a directory is whitelisted in an ignore file, then it will be searched even if this flag isn't provided. Similarly if a hidden file or directory is given explicitly as an argumnet to ripgrep. .sp A file or directory is considered hidden if its base name starts with a dot character (\fB.\fP). On operating systems which support a "hidden" file attribute, like Windows, files with this attribute are also considered hidden. .sp This flag can be disabled with \fB\-\-no-hidden\fP. .RE .sp \fB\-\-iglob\fP=\fIGLOB\fP .RS 4 Include or exclude files and directories for searching that match the given glob. This always overrides any other ignore logic. Multiple glob flags may be used. Globbing rules match \fB.gitignore\fP globs. Precede a glob with a \fB!\fP to exclude it. If multiple globs match a file or directory, the glob given later in the command line takes precedence. Globs used via this flag are matched case insensitively. .RE .sp \fB\-\-ignore-file\fP=\fIPATH\fP .RS 4 Specifies a path to one or more \fBgitignore\fP formatted rules files. These patterns are applied after the patterns found in \fB.gitignore\fP, \fB.rgignore\fP and \fB.ignore\fP are applied and are matched relative to the current working directory. Multiple additional ignore files can be specified by using this flag repeatedly. When specifying multiple ignore files, earlier files have lower precedence than later files. .sp If you are looking for a way to include or exclude files and directories directly on the command line, then use \fB\-g/\-\-glob\fP instead. .RE .sp \fB\-\-ignore-file-case-insensitive\fP .RS 4 Process ignore files (\fB.gitignore\fP, \fB.ignore\fP, etc.) case insensitively. Note that this comes with a performance penalty and is most useful on case insensitive file systems (such as Windows). .sp This flag can be disabled with \fB\-\-no-ignore-file-case-insensitive\fP. .RE .sp \fB\-d\fP \fINUM\fP, \fB\-\-max-depth\fP=\fINUM\fP .RS 4 This flag limits the depth of directory traversal to \fINUM\fP levels beyond the paths given. A value of \fB0\fP only searches the explicitly given paths themselves. .sp For example, \fBrg --max-depth 0 \fP\fIdir/\fP is a no-op because \fIdir/\fP will not be descended into. \fBrg --max-depth 1 \fP\fIdir/\fP will search only the direct children of \fIdir\fP. .sp An alternative spelling for this flag is \fB\-\-maxdepth\fP. .RE .sp \fB\-\-max-filesize\fP=\fINUM+SUFFIX?\fP .RS 4 Ignore files larger than \fINUM\fP in size. This does not apply to directories. .sp The input format accepts suffixes of \fBK\fP, \fBM\fP or \fBG\fP which correspond to kilobytes, megabytes and gigabytes, respectively. If no suffix is provided the input is treated as bytes. .sp Examples: \fB\-\-max-filesize 50K\fP or \fB\-\-max\-filesize 80M\fP. .RE .sp \fB\-\-no-ignore\fP .RS 4 When set, ignore files such as \fB.gitignore\fP, \fB.ignore\fP and \fB.rgignore\fP will not be respected. This implies \fB\-\-no-ignore-dot\fP, \fB\-\-no-ignore-exclude\fP, \fB\-\-no-ignore-global\fP, \fB\-\-no-ignore-parent\fP and \fB\-\-no-ignore-vcs\fP. .sp This does not imply \fB\-\-no-ignore-files\fP, since \fB\-\-ignore-file\fP is specified explicitly as a command line argument. .sp When given only once, the \fB\-u/\-\-unrestricted\fP flag is identical in behavior to this flag and can be considered an alias. However, subsequent \fB\-u/\-\-unrestricted\fP flags have additional effects. .sp This flag can be disabled with \fB\-\-ignore\fP. .RE .sp \fB\-\-no-ignore-dot\fP .RS 4 Don't respect filter rules from \fB.ignore\fP or \fB.rgignore\fP files. .sp This does not impact whether ripgrep will ignore files and directories whose names begin with a dot. For that, see the \fB\-./\-\-hidden\fP flag. This flag also does not impact whether filter rules from \fB.gitignore\fP files are respected. .sp This flag can be disabled with \fB\-\-ignore-dot\fP. .RE .sp \fB\-\-no-ignore-exclude\fP .RS 4 Don't respect filter rules from files that are manually configured for the repository. For example, this includes \fBgit\fP's \fB.git/info/exclude\fP. .sp This flag can be disabled with \fB\-\-ignore-exclude\fP. .RE .sp \fB\-\-no-ignore-files\fP .RS 4 When set, any \fB\-\-ignore-file\fP flags, even ones that come after this flag, are ignored. .sp This flag can be disabled with \fB\-\-ignore-files\fP. .RE .sp \fB\-\-no-ignore-global\fP .RS 4 Don't respect filter rules from ignore files that come from "global" sources such as \fBgit\fP's \fBcore.excludesFile\fP configuration option (which defaults to \fB$HOME/.config/git/ignore\fP). .sp This flag can be disabled with \fB\-\-ignore-global\fP. .RE .sp \fB\-\-no-ignore-parent\fP .RS 4 When this flag is set, filter rules from ignore files found in parent directories are not respected. By default, ripgrep will ascend the parent directories of the current working directory to look for any applicable ignore files that should be applied. In some cases this may not be desirable. .sp This flag can be disabled with \fB\-\-ignore-parent\fP. .RE .sp \fB\-\-no-ignore-vcs\fP .RS 4 When given, filter rules from source control ignore files (e.g., \fB.gitignore\fP) are not respected. By default, ripgrep respects \fBgit\fP's ignore rules for automatic filtering. In some cases, it may not be desirable to respect the source control's ignore rules and instead only respect rules in \fB.ignore\fP or \fB.rgignore\fP. .sp This flag implies \fB\-\-no-ignore-parent\fP for source control ignore files as well. .sp This flag can be disabled with \fB\-\-ignore-vcs\fP. .RE .sp \fB\-\-no-require-git\fP .RS 4 When this flag is given, source control ignore files such as \fB.gitignore\fP are respected even if no \fBgit\fP repository is present. .sp By default, ripgrep will only respect filter rules from source control ignore files when ripgrep detects that the search is executed inside a source control repository. For example, when a \fB.git\fP directory is observed. .sp This flag relaxes the default restriction. For example, it might be useful when the contents of a \fBgit\fP repository are stored or copied somewhere, but where the repository state is absent. .sp This flag can be disabled with \fB\-\-require-git\fP. .RE .sp \fB\-\-one-file-system\fP .RS 4 When enabled, ripgrep will not cross file system boundaries relative to where the search started from. .sp Note that this applies to each path argument given to ripgrep. For example, in the command .sp .EX rg \-\-one\-file\-system /foo/bar /quux/baz .EE .sp ripgrep will search both \fI/foo/bar\fP and \fI/quux/baz\fP even if they are on different file systems, but will not cross a file system boundary when traversing each path's directory tree. .sp This is similar to \fBfind\fP's \fB\-xdev\fP or \fB\-mount\fP flag. .sp This flag can be disabled with \fB\-\-no-one-file-system\fP. .RE .sp \fB\-t\fP \fITYPE\fP, \fB\-\-type\fP=\fITYPE\fP .RS 4 This flag limits ripgrep to searching files matching \fITYPE\fP. Multiple \fB\-t/\-\-type\fP flags may be provided. .sp This flag supports the special value \fBall\fP, which will behave as if \fB\-t/\-\-type\fP was provided for every file type supported by ripgrep (including any custom file types). The end result is that \fB\-\-type=all\fP causes ripgrep to search in "whitelist" mode, where it will only search files it recognizes via its type definitions. .sp Note that this flag has lower precedence than both the \fB\-g/\-\-glob\fP flag and any rules found in ignore files. .sp To see the list of available file types, use the \fB\-\-type-list\fP flag. .RE .sp \fB\-T\fP \fITYPE\fP, \fB\-\-type-not\fP=\fITYPE\fP .RS 4 Do not search files matching \fITYPE\fP. Multiple \fB\-T/\-\-type-not\fP flags may be provided. Use the \fB\-\-type-list\fP flag to list all available types. .sp This flag supports the special value \fBall\fP, which will behave as if \fB\-T/\-\-type-not\fP was provided for every file type supported by ripgrep (including any custom file types). The end result is that \fB\-\-type\-not=all\fP causes ripgrep to search in "blacklist" mode, where it will only search files that are unrecognized by its type definitions. .sp To see the list of available file types, use the \fB\-\-type-list\fP flag. .RE .sp \fB\-\-type-add\fP=\fITYPESPEC\fP .RS 4 This flag adds a new glob for a particular file type. Only one glob can be added at a time. Multiple \fB\-\-type-add\fP flags can be provided. Unless \fB\-\-type-clear\fP is used, globs are added to any existing globs defined inside of ripgrep. .sp Note that this must be passed to every invocation of ripgrep. Type settings are not persisted. See \fBCONFIGURATION FILES\fP for a workaround. .sp Example: .sp .EX rg \-\-type\-add 'foo:*.foo' -tfoo \fIPATTERN\fP .EE .sp This flag can also be used to include rules from other types with the special include directive. The include directive permits specifying one or more other type names (separated by a comma) that have been defined and its rules will automatically be imported into the type specified. For example, to create a type called src that matches C++, Python and Markdown files, one can use: .sp .EX \-\-type\-add 'src:include:cpp,py,md' .EE .sp Additional glob rules can still be added to the src type by using this flag again: .sp .EX \-\-type\-add 'src:include:cpp,py,md' \-\-type\-add 'src:*.foo' .EE .sp Note that type names must consist only of Unicode letters or numbers. Punctuation characters are not allowed. .RE .sp \fB\-\-type-clear\fP=\fITYPE\fP .RS 4 Clear the file type globs previously defined for \fITYPE\fP. This clears any previously defined globs for the \fITYPE\fP, but globs can be added after this flag. .sp Note that this must be passed to every invocation of ripgrep. Type settings are not persisted. See \fBCONFIGURATION FILES\fP for a workaround. .RE .sp \fB\-u\fP, \fB\-\-unrestricted\fP .RS 4 This flag reduces the level of "smart" filtering. Repeated uses (up to 3) reduces the filtering even more. When repeated three times, ripgrep will search every file in a directory tree. .sp A single \fB\-u/\-\-unrestricted\fP flag is equivalent to \fB\-\-no-ignore\fP. Two \fB\-u/\-\-unrestricted\fP flags is equivalent to \fB\-\-no-ignore\fP \fB\-./\-\-hidden\fP. Three \fB\-u/\-\-unrestricted\fP flags is equivalent to \fB\-\-no-ignore\fP \fB\-./\-\-hidden\fP \fB\-\-binary\fP. .sp The only filtering ripgrep still does when \fB-uuu\fP is given is to skip symbolic links and to avoid printing matches from binary files. Symbolic links can be followed via the \fB\-L/\-\-follow\fP flag, and binary files can be treated as text files via the \fB\-a/\-\-text\fP flag. .RE . .SS OUTPUT OPTIONS \fB\-A\fP \fINUM\fP, \fB\-\-after-context\fP=\fINUM\fP .RS 4 Show \fINUM\fP lines after each match. .sp This overrides the \fB\-\-passthru\fP flag and partially overrides the \fB\-C/\-\-context\fP flag. .RE .sp \fB\-B\fP \fINUM\fP, \fB\-\-before-context\fP=\fINUM\fP .RS 4 Show \fINUM\fP lines before each match. .sp This overrides the \fB\-\-passthru\fP flag and partially overrides the \fB\-C/\-\-context\fP flag. .RE .sp \fB\-\-block-buffered\fP .RS 4 When enabled, ripgrep will use block buffering. That is, whenever a matching line is found, it will be written to an in-memory buffer and will not be written to stdout until the buffer reaches a certain size. This is the default when ripgrep's stdout is redirected to a pipeline or a file. When ripgrep's stdout is connected to a tty, line buffering will be used by default. Forcing block buffering can be useful when dumping a large amount of contents to a tty. .sp This overrides the \fB\-\-line-buffered\fP flag. .sp This flag can be disabled with \fB\-\-no-block-buffered\fP. .RE .sp \fB\-b\fP, \fB\-\-byte-offset\fP .RS 4 Print the 0-based byte offset within the input file before each line of output. If \fB\-o/\-\-only-matching\fP is specified, print the offset of the matched text itself. .sp If ripgrep does transcoding, then the byte offset is in terms of the result of transcoding and not the original data. This applies similarly to other transformations on the data, such as decompression or a \fB\-\-pre\fP filter. .sp This flag can be disabled with \fB\-\-no-byte-offset\fP. .RE .sp \fB\-\-color\fP=\fIWHEN\fP .RS 4 This flag controls when to use colors. The default setting is \fBauto\fP, which means ripgrep will try to guess when to use colors. For example, if ripgrep is printing to a tty, then it will use colors, but if it is redirected to a file or a pipe, then it will suppress color output. .sp ripgrep will suppress color output by default in some other circumstances as well. These include, but are not limited to: .sp .IP \(bu 3n When the \fBTERM\fP environment variable is not set or set to \fBdumb\fP. .sp .IP \(bu 3n When the \fBNO_COLOR\fP environment variable is set (regardless of value). .sp .IP \(bu 3n When flags that imply no use for colors are given. For example, \fB\-\-vimgrep\fP and \fB\-\-json\fP. . .PP The possible values for this flag are: .sp .IP \fBnever\fP 10n Colors will never be used. .sp .IP \fBauto\fP 10n The default. ripgrep tries to be smart. .sp .IP \fBalways\fP 10n Colors will always be used regardless of where output is sent. .sp .IP \fBansi\fP 10n Like 'always', but emits ANSI escapes (even in a Windows console). . .PP This flag also controls whether hyperlinks are emitted. For example, when a hyperlink format is specified, hyperlinks won't be used when color is suppressed. If one wants to emit hyperlinks but no colors, then one must use the \fB\-\-colors\fP flag to manually set all color styles to \fBnone\fP: .sp .EX \-\-colors 'path:none' \\ \-\-colors 'line:none' \\ \-\-colors 'column:none' \\ \-\-colors 'match:none' .EE .sp .RE .sp \fB\-\-colors\fP=\fICOLOR_SPEC\fP .RS 4 This flag specifies color settings for use in the output. This flag may be provided multiple times. Settings are applied iteratively. Pre-existing color labels are limited to one of eight choices: \fBred\fP, \fBblue\fP, \fBgreen\fP, \fBcyan\fP, \fBmagenta\fP, \fByellow\fP, \fBwhite\fP and \fBblack\fP. Styles are limited to \fBnobold\fP, \fBbold\fP, \fBnointense\fP, \fBintense\fP, \fBnounderline\fP or \fBunderline\fP. .sp The format of the flag is \fB{\fP\fItype\fP\fB}:{\fP\fIattribute\fP\fB}:{\fP\fIvalue\fP\fB}\fP. \fItype\fP should be one of \fBpath\fP, \fBline\fP, \fBcolumn\fP or \fBmatch\fP. \fIattribute\fP can be \fBfg\fP, \fBbg\fP or \fBstyle\fP. \fIvalue\fP is either a color (for \fBfg\fP and \fBbg\fP) or a text style. A special format, \fB{\fP\fItype\fP\fB}:none\fP, will clear all color settings for \fItype\fP. .sp For example, the following command will change the match color to magenta and the background color for line numbers to yellow: .sp .EX rg \-\-colors 'match:fg:magenta' \-\-colors 'line:bg:yellow' .EE .sp Extended colors can be used for \fIvalue\fP when the tty supports ANSI color sequences. These are specified as either \fIx\fP (256-color) or .IB x , x , x (24-bit truecolor) where \fIx\fP is a number between \fB0\fP and \fB255\fP inclusive. \fIx\fP may be given as a normal decimal number or a hexadecimal number, which is prefixed by \fB0x\fP. .sp For example, the following command will change the match background color to that represented by the rgb value (0,128,255): .sp .EX rg \-\-colors 'match:bg:0,128,255' .EE .sp or, equivalently, .sp .EX rg \-\-colors 'match:bg:0x0,0x80,0xFF' .EE .sp Note that the \fBintense\fP and \fBnointense\fP styles will have no effect when used alongside these extended color codes. .RE .sp \fB\-\-column\fP .RS 4 Show column numbers (1-based). This only shows the column numbers for the first match on each line. This does not try to account for Unicode. One byte is equal to one column. This implies \fB\-n/\-\-line-number\fP. .sp When \fB\-o/\-\-only-matching\fP is used, then the column numbers written correspond to the start of each match. .sp This flag can be disabled with \fB\-\-no-column\fP. .RE .sp \fB\-C\fP \fINUM\fP, \fB\-\-context\fP=\fINUM\fP .RS 4 Show \fINUM\fP lines before and after each match. This is equivalent to providing both the \fB\-B/\-\-before-context\fP and \fB\-A/\-\-after-context\fP flags with the same value. .sp This overrides the \fB\-\-passthru\fP flag. The \fB\-A/\-\-after-context\fP and \fB\-B/\-\-before-context\fP flags both partially override this flag, regardless of the order. For example, \fB\-A2 \-C1\fP is equivalent to \fB\-A2 \-B1\fP. .RE .sp \fB\-\-context-separator\fP=\fISEPARATOR\fP .RS 4 The string used to separate non-contiguous context lines in the output. This is only used when one of the context flags is used (that is, \fB\-A/\-\-after-context\fP, \fB\-B/\-\-before-context\fP or \fB\-C/\-\-context\fP). Escape sequences like \fB\\x7F\fP or \fB\\t\fP may be used. The default value is \fB\-\-\fP. .sp When the context separator is set to an empty string, then a line break is still inserted. To completely disable context separators, use the \fB\-\-no-context-separator\fP flag. .RE .sp \fB\-\-field-context-separator\fP=\fISEPARATOR\fP .RS 4 Set the field context separator. This separator is only used when printing contextual lines. It is used to delimit file paths, line numbers, columns and the contextual line itself. The separator may be any number of bytes, including zero. Escape sequences like \fB\\x7F\fP or \fB\\t\fP may be used. .sp The \fB-\fP character is the default value. .RE .sp \fB\-\-field-match-separator\fP=\fISEPARATOR\fP .RS 4 Set the field match separator. This separator is only used when printing matching lines. It is used to delimit file paths, line numbers, columns and the matching line itself. The separator may be any number of bytes, including zero. Escape sequences like \fB\\x7F\fP or \fB\\t\fP may be used. .sp The \fB:\fP character is the default value. .RE .sp \fB\-\-heading\fP .RS 4 This flag prints the file path above clusters of matches from each file instead of printing the file path as a prefix for each matched line. .sp This is the default mode when printing to a tty. .sp When \fBstdout\fP is not a tty, then ripgrep will default to the standard grep-like format. Once can force this format in Unix-like environments by piping the output of ripgrep to \fBcat\fP. For example, \fBrg\fP \fIfoo\fP \fB| cat\fP. .sp This flag can be disabled with \fB\-\-no-heading\fP. .RE .sp \fB\-h\fP, \fB\-\-help\fP .RS 4 This flag prints the help output for ripgrep. .sp Unlike most other flags, the behavior of the short flag, \fB\-h\fP, and the long flag, \fB\-\-help\fP, is different. The short flag will show a condensed help output while the long flag will show a verbose help output. The verbose help output has complete documentation, where as the condensed help output will show only a single line for every flag. .RE .sp \fB\-\-hostname-bin\fP=\fICOMMAND\fP .RS 4 This flag controls how ripgrep determines this system's hostname. The flag's value should correspond to an executable (either a path or something that can be found via your system's \fBPATH\fP environment variable). When set, ripgrep will run this executable, with no arguments, and treat its output (with leading and trailing whitespace stripped) as your system's hostname. .sp When not set (the default, or the empty string), ripgrep will try to automatically detect your system's hostname. On Unix, this corresponds to calling \fBgethostname\fP. On Windows, this corresponds to calling \fBGetComputerNameExW\fP to fetch the system's "physical DNS hostname." .sp ripgrep uses your system's hostname for producing hyperlinks. .RE .sp \fB\-\-hyperlink-format\fP=\fIFORMAT\fP .RS 4 Set the format of hyperlinks to use when printing results. Hyperlinks make certain elements of ripgrep's output, such as file paths, clickable. This generally only works in terminal emulators that support OSC-8 hyperlinks. For example, the format \fBfile://{host}{path}\fP will emit an RFC 8089 hyperlink. To see the format that ripgrep is using, pass the \fB\-\-debug\fP flag. .sp Alternatively, a format string may correspond to one of the following aliases: \fBdefault\fP, \fBnone\fP, \fBfile\fP, \fBgrep+\fP, \fBkitty\fP, \fBmacvim\fP, \fBtextmate\fP, \fBvscode\fP, \fBvscode-insiders\fP, \fBvscodium\fP. The alias will be replaced with a format string that is intended to work for the corresponding application. .sp The following variables are available in the format string: .sp .TP 12 \fB{path}\fP Required. This is replaced with a path to a matching file. The path is guaranteed to be absolute and percent encoded such that it is valid to put into a URI. Note that a path is guaranteed to start with a /. .TP 12 \fB{host}\fP Optional. This is replaced with your system's hostname. On Unix, this corresponds to calling \fBgethostname\fP. On Windows, this corresponds to calling \fBGetComputerNameExW\fP to fetch the system's "physical DNS hostname." Alternatively, if \fB\-\-hostname-bin\fP was provided, then the hostname returned from the output of that program will be returned. If no hostname could be found, then this variable is replaced with the empty string. .TP 12 \fB{line}\fP Optional. If appropriate, this is replaced with the line number of a match. If no line number is available (for example, if \fB\-\-no\-line\-number\fP was given), then it is automatically replaced with the value 1. .TP 12 \fB{column}\fP Optional, but requires the presence of \fB{line}\fP. If appropriate, this is replaced with the column number of a match. If no column number is available (for example, if \fB\-\-no\-column\fP was given), then it is automatically replaced with the value 1. .TP 12 \fB{wslprefix}\fP Optional. This is a special value that is set to \fBwsl$/\fP\fIWSL_DISTRO_NAME\fP, where \fIWSL_DISTRO_NAME\fP corresponds to the value of the equivalent environment variable. If the system is not Unix or if the \fIWSL_DISTRO_NAME\fP environment variable is not set, then this is replaced with the empty string. .PP A format string may be empty. An empty format string is equivalent to the \fBnone\fP alias. In this case, hyperlinks will be disabled. .sp At present, ripgrep does not enable hyperlinks by default. Users must opt into them. If you aren't sure what format to use, try \fBdefault\fP. .sp Like colors, when ripgrep detects that stdout is not connected to a tty, then hyperlinks are automatically disabled, regardless of the value of this flag. Users can pass \fB\-\-color=always\fP to forcefully emit hyperlinks. .sp Note that hyperlinks are only written when a path is also in the output and colors are enabled. To write hyperlinks without colors, you'll need to configure ripgrep to not colorize anything without actually disabling all ANSI escape codes completely: .sp .EX \-\-colors 'path:none' \\ \-\-colors 'line:none' \\ \-\-colors 'column:none' \\ \-\-colors 'match:none' .EE .sp ripgrep works this way because it treats the \fB\-\-color\fP flag as a proxy for whether ANSI escape codes should be used at all. This means that environment variables like \fBNO_COLOR=1\fP and \fBTERM=dumb\fP not only disable colors, but hyperlinks as well. Similarly, colors and hyperlinks are disabled when ripgrep is not writing to a tty. (Unless one forces the issue by setting \fB\-\-color=always\fP.) .sp If you're searching a file directly, for example: .sp .EX rg foo path/to/file .EE .sp then hyperlinks will not be emitted since the path given does not appear in the output. To make the path appear, and thus also a hyperlink, use the \fB\-H/\-\-with-filename\fP flag. .sp For more information on hyperlinks in terminal emulators, see: https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda .RE .sp \fB\-\-include-zero\fP .RS 4 When used with \fB\-c/\-\-count\fP or \fB\-\-count-matches\fP, this causes ripgrep to print the number of matches for each file even if there were zero matches. This is disabled by default but can be enabled to make ripgrep behave more like grep. .sp This flag can be disabled with \fB\-\-no-include-zero\fP. .RE .sp \fB\-\-line-buffered\fP .RS 4 When enabled, ripgrep will always use line buffering. That is, whenever a matching line is found, it will be flushed to stdout immediately. This is the default when ripgrep's stdout is connected to a tty, but otherwise, ripgrep will use block buffering, which is typically faster. This flag forces ripgrep to use line buffering even if it would otherwise use block buffering. This is typically useful in shell pipelines, for example: .sp .EX tail -f something.log | rg foo --line-buffered | rg bar .EE .sp This overrides the \fB\-\-block-buffered\fP flag. .sp This flag can be disabled with \fB\-\-no-line-buffered\fP. .RE .sp \fB\-n\fP, \fB\-\-line-number\fP .RS 4 Show line numbers (1-based). .sp This is enabled by default when stdout is connected to a tty. .sp This flag can be disabled by \fB\-N/\-\-no-line-number\fP. .RE .sp \fB\-N\fP, \fB\-\-no-line-number\fP .RS 4 Suppress line numbers. .sp Line numbers are off by default when stdout is not connected to a tty. .sp Line numbers can be forcefully turned on by \fB\-n/\-\-line-number\fP. .RE .sp \fB\-M\fP \fINUM\fP, \fB\-\-max-columns\fP=\fINUM\fP .RS 4 When given, ripgrep will omit lines longer than this limit in bytes. Instead of printing long lines, only the number of matches in that line is printed. .sp When this flag is omitted or is set to \fB0\fP, then it has no effect. .RE .sp \fB\-\-max-columns-preview\fP .RS 4 Prints a preview for lines exceeding the configured max column limit. .sp When the \fB\-M/\-\-max-columns\fP flag is used, ripgrep will by default completely replace any line that is too long with a message indicating that a matching line was removed. When this flag is combined with \fB\-M/\-\-max-columns\fP, a preview of the line (corresponding to the limit size) is shown instead, where the part of the line exceeding the limit is not shown. .sp If the \fB\-M/\-\-max-columns\fP flag is not set, then this has no effect. .sp This flag can be disabled with \fB\-\-no-max-columns-preview\fP. .RE .sp \fB\-0\fP, \fB\-\-null\fP .RS 4 Whenever a file path is printed, follow it with a \fBNUL\fP byte. This includes printing file paths before matches, and when printing a list of matching files such as with \fB\-c/\-\-count\fP, \fB\-l/\-\-files-with-matches\fP and \fB\-\-files\fP. This option is useful for use with \fBxargs\fP. .RE .sp \fB\-o\fP, \fB\-\-only-matching\fP .RS 4 Print only the matched (non-empty) parts of a matching line, with each such part on a separate output line. .RE .sp \fB\-\-path-separator\fP=\fISEPARATOR\fP .RS 4 Set the path separator to use when printing file paths. This defaults to your platform's path separator, which is \fB/\fP on Unix and \fB\\\fP on Windows. This flag is intended for overriding the default when the environment demands it (e.g., cygwin). A path separator is limited to a single byte. .sp Setting this flag to an empty string reverts it to its default behavior. That is, the path separator is automatically chosen based on the environment. .RE .sp \fB\-\-passthru\fP .RS 4 Print both matching and non-matching lines. .sp Another way to achieve a similar effect is by modifying your pattern to match the empty string. For example, if you are searching using \fBrg\fP \fIfoo\fP, then using \fBrg\fP \fB'^|\fP\fIfoo\fP\fB'\fP instead will emit every line in every file searched, but only occurrences of \fIfoo\fP will be highlighted. This flag enables the same behavior without needing to modify the pattern. .sp An alternative spelling for this flag is \fB\-\-passthrough\fP. .sp This overrides the \fB\-C/\-\-context\fP, \fB\-A/\-\-after-context\fP and \fB\-B/\-\-before-context\fP flags. .RE .sp \fB\-p\fP, \fB\-\-pretty\fP .RS 4 This is a convenience alias for \fB\-\-color=always \-\-heading \-\-line\-number\fP. This flag is useful when you still want pretty output even if you're piping ripgrep to another program or file. For example: \fBrg -p \fP\fIfoo\fP \fB| less -R\fP. .RE .sp \fB\-q\fP, \fB\-\-quiet\fP .RS 4 Do not print anything to stdout. If a match is found in a file, then ripgrep will stop searching. This is useful when ripgrep is used only for its exit code (which will be an error code if no matches are found). .sp When \fB\-\-files\fP is used, ripgrep will stop finding files after finding the first file that does not match any ignore rules. .RE .sp \fB\-r\fP \fIREPLACEMENT\fP, \fB\-\-replace\fP=\fIREPLACEMENT\fP .RS 4 Replaces every match with the text given when printing results. Neither this flag nor any other ripgrep flag will modify your files. .sp Capture group indices (e.g., \fB$\fP\fI5\fP) and names (e.g., \fB$\fP\fIfoo\fP) are supported in the replacement string. Capture group indices are numbered based on the position of the opening parenthesis of the group, where the leftmost such group is \fB$\fP\fI1\fP. The special \fB$\fP\fI0\fP group corresponds to the entire match. .sp The name of a group is formed by taking the longest string of letters, numbers and underscores (i.e. \fB[_0-9A-Za-z]\fP) after the \fB$\fP. For example, \fB$\fP\fI1a\fP will be replaced with the group named \fI1a\fP, not the group at index \fI1\fP. If the group's name contains characters that aren't letters, numbers or underscores, or you want to immediately follow the group with another string, the name should be put inside braces. For example, \fB${\fP\fI1\fP\fB}\fP\fIa\fP will take the content of the group at index \fI1\fP and append \fIa\fP to the end of it. .sp If an index or name does not refer to a valid capture group, it will be replaced with an empty string. .sp In shells such as Bash and zsh, you should wrap the pattern in single quotes instead of double quotes. Otherwise, capture group indices will be replaced by expanded shell variables which will most likely be empty. .sp To write a literal \fB$\fP, use \fB$$\fP. .sp Note that the replacement by default replaces each match, and not the entire line. To replace the entire line, you should match the entire line. .sp This flag can be used with the \fB\-o/\-\-only-matching\fP flag. .RE .sp \fB\-\-sort\fP=\fISORTBY\fP .RS 4 This flag enables sorting of results in ascending order. The possible values for this flag are: .sp .TP 12 \fBnone\fP (Default) Do not sort results. Fastest. Can be multi-threaded. .TP 12 \fBpath\fP Sort by file path. Always single-threaded. The order is determined by sorting files in each directory entry during traversal. This means that given the files \fBa/b\fP and \fBa+\fP, the latter will sort after the former even though \fB+\fP would normally sort before \fB/\fP. .TP 12 \fBmodified\fP Sort by the last modified time on a file. Always single-threaded. .TP 12 \fBaccessed\fP Sort by the last accessed time on a file. Always single-threaded. .TP 12 \fBcreated\fP Sort by the creation time on a file. Always single-threaded. .PP If the chosen (manually or by-default) sorting criteria isn't available on your system (for example, creation time is not available on ext4 file systems), then ripgrep will attempt to detect this, print an error and exit without searching. .sp To sort results in reverse or descending order, use the \fB\-\-sortr\fP flag. Also, this flag overrides \fB\-\-sortr\fP. .sp Note that sorting results currently always forces ripgrep to abandon parallelism and run in a single thread. .RE .sp \fB\-\-sortr\fP=\fISORTBY\fP .RS 4 This flag enables sorting of results in descending order. The possible values for this flag are: .sp .TP 12 \fBnone\fP (Default) Do not sort results. Fastest. Can be multi-threaded. .TP 12 \fBpath\fP Sort by file path. Always single-threaded. The order is determined by sorting files in each directory entry during traversal. This means that given the files \fBa/b\fP and \fBa+\fP, the latter will sort before the former even though \fB+\fP would normally sort after \fB/\fP when doing a reverse lexicographic sort. .TP 12 \fBmodified\fP Sort by the last modified time on a file. Always single-threaded. .TP 12 \fBaccessed\fP Sort by the last accessed time on a file. Always single-threaded. .TP 12 \fBcreated\fP Sort by the creation time on a file. Always single-threaded. .PP If the chosen (manually or by-default) sorting criteria isn't available on your system (for example, creation time is not available on ext4 file systems), then ripgrep will attempt to detect this, print an error and exit without searching. .sp To sort results in ascending order, use the \fB\-\-sort\fP flag. Also, this flag overrides \fB\-\-sort\fP. .sp Note that sorting results currently always forces ripgrep to abandon parallelism and run in a single thread. .RE .sp \fB\-\-trim\fP .RS 4 When set, all ASCII whitespace at the beginning of each line printed will be removed. .sp This flag can be disabled with \fB\-\-no-trim\fP. .RE .sp \fB\-\-vimgrep\fP .RS 4 This flag instructs ripgrep to print results with every match on its own line, including line numbers and column numbers. .sp With this option, a line with more than one match will be printed in its entirety more than once. For that reason, the total amount of output as a result of this flag can be quadratic in the size of the input. For example, if the pattern matches every byte in an input file, then each line will be repeated for every byte matched. For this reason, users should only use this flag when there is no other choice. Editor integrations should prefer some other way of reading results from ripgrep, such as via the \fB\-\-json\fP flag. One alternative to avoiding exorbitant memory usage is to force ripgrep into single threaded mode with the \fB\-j/\-\-threads\fP flag. Note though that this will not impact the total size of the output, just the heap memory that ripgrep will use. .RE .sp \fB\-H\fP, \fB\-\-with-filename\fP .RS 4 This flag instructs ripgrep to print the file path for each matching line. This is the default when more than one file is searched. If \fB\-\-heading\fP is enabled (the default when printing to a tty), the file path will be shown above clusters of matches from each file; otherwise, the file name will be shown as a prefix for each matched line. .sp This flag overrides \fB\-I/\-\-no-filename\fP. .RE .sp \fB\-I\fP, \fB\-\-no-filename\fP .RS 4 This flag instructs ripgrep to never print the file path with each matching line. This is the default when ripgrep is explicitly instructed to search one file or stdin. .sp This flag overrides \fB\-H/\-\-with-filename\fP. .RE .sp \fB\-\-sort-files\fP .RS 4 DEPRECATED. Use \fB\-\-sort=path\fP instead. .sp This flag instructs ripgrep to sort search results by file path lexicographically in ascending order. Note that this currently disables all parallelism and runs search in a single thread. .sp This flag overrides \fB\-\-sort\fP and \fB\-\-sortr\fP. .sp This flag can be disabled with \fB\-\-no-sort-files\fP. .RE . .SS OUTPUT MODES \fB\-c\fP, \fB\-\-count\fP .RS 4 This flag suppresses normal output and shows the number of lines that match the given patterns for each file searched. Each file containing a match has its path and count printed on each line. Note that unless \fB\-U/\-\-multiline\fP is enabled, this reports the number of lines that match and not the total number of matches. In multiline mode, \fB\-c/\-\-count\fP is equivalent to \fB\-\-count-matches\fP. .sp If only one file is given to ripgrep, then only the count is printed if there is a match. The \fB\-H/\-\-with-filename\fP flag can be used to force printing the file path in this case. If you need a count to be printed regardless of whether there is a match, then use \fB\-\-include-zero\fP. .sp This overrides the \fB\-\-count-matches\fP flag. Note that when \fB\-c/\-\-count\fP is combined with \fB\-o/\-\-only-matching\fP, then ripgrep behaves as if \fB\-\-count-matches\fP was given. .RE .sp \fB\-\-count-matches\fP .RS 4 This flag suppresses normal output and shows the number of individual matches of the given patterns for each file searched. Each file containing matches has its path and match count printed on each line. Note that this reports the total number of individual matches and not the number of lines that match. .sp If only one file is given to ripgrep, then only the count is printed if there is a match. The \fB\-H/\-\-with-filename\fP flag can be used to force printing the file path in this case. .sp This overrides the \fB\-c/\-\-count\fP flag. Note that when \fB\-c/\-\-count\fP is combined with \fB\-o/\-\-only-matching\fP, then ripgrep behaves as if \fB\-\-count-matches\fP was given. .RE .sp \fB\-l\fP, \fB\-\-files-with-matches\fP .RS 4 Print only the paths with at least one match and suppress match contents. .sp This overrides \fB\-\-files-without-match\fP. .RE .sp \fB\-\-files-without-match\fP .RS 4 Print the paths that contain zero matches and suppress match contents. .sp This overrides \fB\-l/\-\-files-with-matches\fP. .RE .sp \fB\-\-json\fP .RS 4 Enable printing results in a JSON Lines format. .sp When this flag is provided, ripgrep will emit a sequence of messages, each encoded as a JSON object, where there are five different message types: .sp .TP 12 \fBbegin\fP A message that indicates a file is being searched and contains at least one match. .TP 12 \fBend\fP A message the indicates a file is done being searched. This message also include summary statistics about the search for a particular file. .TP 12 \fBmatch\fP A message that indicates a match was found. This includes the text and offsets of the match. .TP 12 \fBcontext\fP A message that indicates a contextual line was found. This includes the text of the line, along with any match information if the search was inverted. .TP 12 \fBsummary\fP The final message emitted by ripgrep that contains summary statistics about the search across all files. .PP Since file paths or the contents of files are not guaranteed to be valid UTF-8 and JSON itself must be representable by a Unicode encoding, ripgrep will emit all data elements as objects with one of two keys: \fBtext\fP or \fBbytes\fP. \fBtext\fP is a normal JSON string when the data is valid UTF-8 while \fBbytes\fP is the base64 encoded contents of the data. .sp The JSON Lines format is only supported for showing search results. It cannot be used with other flags that emit other types of output, such as \fB\-\-files\fP, \fB\-l/\-\-files-with-matches\fP, \fB\-\-files-without-match\fP, \fB\-c/\-\-count\fP or \fB\-\-count-matches\fP. ripgrep will report an error if any of the aforementioned flags are used in concert with \fB\-\-json\fP. .sp Other flags that control aspects of the standard output such as \fB\-o/\-\-only-matching\fP, \fB\-\-heading\fP, \fB\-r/\-\-replace\fP, \fB\-M/\-\-max-columns\fP, etc., have no effect when \fB\-\-json\fP is set. However, enabling JSON output will always implicitly and unconditionally enable \fB\-\-stats\fP. .sp A more complete description of the JSON format used can be found here: \fIhttps://docs.rs/grep-printer/*/grep_printer/struct.JSON.html\fP. .sp This flag can be disabled with \fB\-\-no-json\fP. .RE . .SS LOGGING OPTIONS \fB\-\-debug\fP .RS 4 Show debug messages. Please use this when filing a bug report. .sp The \fB\-\-debug\fP flag is generally useful for figuring out why ripgrep skipped searching a particular file. The debug messages should mention all files skipped and why they were skipped. .sp To get even more debug output, use the \fB\-\-trace\fP flag, which implies \fB\-\-debug\fP along with additional trace data. .RE .sp \fB\-\-no-ignore-messages\fP .RS 4 When this flag is enabled, all error messages related to parsing ignore files are suppressed. By default, error messages are printed to stderr. In cases where these errors are expected, this flag can be used to avoid seeing the noise produced by the messages. .sp This flag can be disabled with \fB\-\-ignore-messages\fP. .RE .sp \fB\-\-no-messages\fP .RS 4 This flag suppresses some error messages. Specifically, messages related to the failed opening and reading of files. Error messages related to the syntax of the pattern are still shown. .sp This flag can be disabled with \fB\-\-messages\fP. .RE .sp \fB\-\-stats\fP .RS 4 When enabled, ripgrep will print aggregate statistics about the search. When this flag is present, ripgrep will print at least the following stats to stdout at the end of the search: number of matched lines, number of files with matches, number of files searched, and the time taken for the entire search to complete. .sp This set of aggregate statistics may expand over time. .sp This flag is always and implicitly enabled when \fB\-\-json\fP is used. .sp Note that this flag has no effect if \fB\-\-files\fP, \fB\-l/\-\-files-with-matches\fP or \fB\-\-files-without-match\fP is passed. .sp This flag can be disabled with \fB\-\-no-stats\fP. .RE .sp \fB\-\-trace\fP .RS 4 Show trace messages. This shows even more detail than the \fB\-\-debug\fP flag. Generally, one should only use this if \fB\-\-debug\fP doesn't emit the information you're looking for. .RE . .SS OTHER BEHAVIORS \fB\-\-files\fP .RS 4 Print each file that would be searched without actually performing the search. This is useful to determine whether a particular file is being searched or not. .sp This overrides \fB\-\-type-list\fP. .RE .sp \fB\-\-generate\fP=\fIKIND\fP .RS 4 This flag instructs ripgrep to generate some special kind of output identified by \fIKIND\fP and then quit without searching. \fIKIND\fP can be one of the following values: .sp .TP 15 \fBman\fP Generates a manual page for ripgrep in the \fBroff\fP format. .TP 15 \fBcomplete\-bash\fP Generates a completion script for the \fBbash\fP shell. .TP 15 \fBcomplete\-zsh\fP Generates a completion script for the \fBzsh\fP shell. .TP 15 \fBcomplete\-fish\fP Generates a completion script for the \fBfish\fP shell. .TP 15 \fBcomplete\-powershell\fP Generates a completion script for PowerShell. .PP The output is written to \fBstdout\fP. The list above may expand over time. .RE .sp \fB\-\-no-config\fP .RS 4 When set, ripgrep will never read configuration files. When this flag is present, ripgrep will not respect the \fBRIPGREP_CONFIG_PATH\fP environment variable. .sp If ripgrep ever grows a feature to automatically read configuration files in pre-defined locations, then this flag will also disable that behavior as well. .RE .sp \fB\-\-pcre2-version\fP .RS 4 When this flag is present, ripgrep will print the version of PCRE2 in use, along with other information, and then exit. If PCRE2 is not available, then ripgrep will print an error message and exit with an error code. .RE .sp \fB\-\-type-list\fP .RS 4 Show all supported file types and their corresponding globs. This takes any \fB\-\-type-add\fP and \fB\-\-type-clear\fP flags given into account. Each type is printed on its own line, followed by a \fB:\fP and then a comma-delimited list of globs for that type on the same line. .RE .sp \fB\-V\fP, \fB\-\-version\fP .RS 4 This flag prints ripgrep's version. This also may print other relevant information, such as the presence of target specific optimizations and the \fBgit\fP revision that this build of ripgrep was compiled from. .RE . . .SH EXIT STATUS If ripgrep finds a match, then the exit status of the program is \fB0\fP. If no match could be found, then the exit status is \fB1\fP. If an error occurred, then the exit status is always \fB2\fP unless ripgrep was run with the \fB\-q/\-\-quiet\fP flag and a match was found. In summary: .sp .IP \(bu 3n \fB0\fP exit status occurs only when at least one match was found, and if no error occurred, unless \fB\-q/\-\-quiet\fP was given. . .IP \(bu 3n \fB1\fP exit status occurs only when no match was found and no error occurred. . .IP \(bu 3n \fB2\fP exit status occurs when an error occurred. This is true for both catastrophic errors (e.g., a regex syntax error) and for soft errors (e.g., unable to read a file). . . .SH AUTOMATIC FILTERING ripgrep does a fair bit of automatic filtering by default. This section describes that filtering and how to control it. .sp \fBTIP\fP: To disable automatic filtering, use \fBrg -uuu\fP. .sp ripgrep's automatic "smart" filtering is one of the most apparent differentiating features between ripgrep and other tools like \fBgrep\fP. As such, its behavior may be surprising to users that aren't expecting it. .sp ripgrep does four types of filtering automatically: .sp . .IP 1. 3n Files and directories that match ignore rules are not searched. .IP 2. 3n Hidden files and directories are not searched. .IP 3. 3n Binary files (files with a \fBNUL\fP byte) are not searched. .IP 4. 3n Symbolic links are not followed. .PP The first type of filtering is the most sophisticated. ripgrep will attempt to respect your \fBgitignore\fP rules as faithfully as possible. In particular, this includes the following: . .IP \(bu 3n Any global rules, e.g., in \fB$HOME/.config/git/ignore\fP. . .IP \(bu 3n Any rules in relevant \fB.gitignore\fP files. This includes \fB.gitignore\fP files in parent directories that are part of the same \fBgit\fP repository. (Unless \fB\-\-no\-require\-git\fP is given.) . .IP \(bu 3n Any local rules, e.g., in \fB.git/info/exclude\fP. .PP In some cases, ripgrep and \fBgit\fP will not always be in sync in terms of which files are ignored. For example, a file that is ignored via \fB.gitignore\fP but is tracked by \fBgit\fP would not be searched by ripgrep even though \fBgit\fP tracks it. This is unlikely to ever be fixed. Instead, you should either make sure your exclude rules match the files you track precisely, or otherwise use \fBgit grep\fP for search. .sp Additional ignore rules can be provided outside of a \fBgit\fP context: . .IP \(bu 3n Any rules in \fB.ignore\fP. ripgrep will also respect \fB.ignore\fP files in parent directories. . .IP \(bu 3n Any rules in \fB.rgignore\fP. ripgrep will also respect \fB.rgignore\fP files in parent directories. . .IP \(bu 3n Any rules in files specified with the \fB\-\-ignore\-file\fP flag. .PP The precedence of ignore rules is as follows, with later items overriding earlier items: . .IP \(bu 3n Files given by \fB\-\-ignore\-file\fP. . .IP \(bu 3n Global gitignore rules, e.g., from \fB$HOME/.config/git/ignore\fP. . .IP \(bu 3n Local rules from \fB.git/info/exclude\fP. . .IP \(bu 3n Rules from \fB.gitignore\fP. . .IP \(bu 3n Rules from \fB.ignore\fP. . .IP \(bu 3n Rules from \fB.rgignore\fP. .PP So for example, if \fIfoo\fP were in a \fB.gitignore\fP and \fB!\fP\fIfoo\fP were in an \fB.rgignore\fP, then \fIfoo\fP would not be ignored since \fB.rgignore\fP takes precedence over \fB.gitignore\fP. .sp Each of the types of filtering can be configured via command line flags: . .IP \(bu 3n There are several flags starting with \fB\-\-no\-ignore\fP that toggle which, if any, ignore rules are respected. \fB\-\-no\-ignore\fP by itself will disable all of them. . .IP \(bu 3n \fB\-./\-\-hidden\fP will force ripgrep to search hidden files and directories. . .IP \(bu 3n \fB\-\-binary\fP will force ripgrep to search binary files. . .IP \(bu 3n \fB\-L/\-\-follow\fP will force ripgrep to follow symlinks. .PP As a special short hand, the \fB\-u\fP flag can be specified up to three times. Each additional time incrementally decreases filtering: . .IP \(bu 3n \fB\-u\fP is equivalent to \fB\-\-no\-ignore\fP. . .IP \(bu 3n \fB\-uu\fP is equivalent to \fB\-\-no\-ignore \-\-hidden\fP. . .IP \(bu 3n \fB\-uuu\fP is equivalent to \fB\-\-no\-ignore \-\-hidden \-\-binary\fP. .PP In particular, \fBrg -uuu\fP should search the same exact content as \fBgrep -r\fP. . . .SH CONFIGURATION FILES ripgrep supports reading configuration files that change ripgrep's default behavior. The format of the configuration file is an "rc" style and is very simple. It is defined by two rules: . .IP 1. 3n Every line is a shell argument, after trimming whitespace. . .IP 2. 3n Lines starting with \fB#\fP (optionally preceded by any amount of whitespace) are ignored. .PP ripgrep will look for a single configuration file if and only if the \fBRIPGREP_CONFIG_PATH\fP environment variable is set and is non-empty. ripgrep will parse arguments from this file on startup and will behave as if the arguments in this file were prepended to any explicit arguments given to ripgrep on the command line. Note though that the \fBrg\fP command you run must still be valid. That is, it must always contain at least one pattern at the command line, even if the configuration file uses the \fB\-e/\-\-regexp\fP flag. .sp For example, if your ripgreprc file contained a single line: .sp .EX \-\-smart\-case .EE .sp then the following command .sp .EX RIPGREP_CONFIG_PATH=wherever/.ripgreprc rg foo .EE .sp would behave identically to the following command: .sp .EX rg \-\-smart-case foo .EE .sp Another example is adding types, like so: .sp .EX \-\-type-add web:*.{html,css,js}* .EE .sp The above would behave identically to the following command: .sp .EX rg \-\-type\-add 'web:*.{html,css,js}*' foo .EE .sp The same applies to using globs. This: .sp .EX \-\-glob=!.git .EE .sp or this: .sp .EX \-\-glob !.git .EE .sp would behave identically to the following command: .sp .EX rg \-\-glob '!.git' foo .EE .sp The bottom line is that every shell argument needs to be on its own line. So for example, a config file containing .sp .EX \-j 4 .EE .sp is probably not doing what you intend. Instead, you want .sp .EX \-j 4 .EE .sp or .sp .EX \-j4 .EE .sp ripgrep also provides a flag, \fB\-\-no\-config\fP, that when present will suppress any and all support for configuration. This includes any future support for auto-loading configuration files from pre-determined paths. .sp Conflicts between configuration files and explicit arguments are handled exactly like conflicts in the same command line invocation. That is, assuming your config file contains only \fB\-\-smart\-case\fP, then this command: .sp .EX RIPGREP_CONFIG_PATH=wherever/.ripgreprc rg foo \-\-case\-sensitive .EE .sp is exactly equivalent to .sp .EX rg \-\-smart\-case foo \-\-case\-sensitive .EE .sp in which case, the \fB\-\-case\-sensitive\fP flag would override the \fB\-\-smart\-case\fP flag. . . .SH SHELL COMPLETION Shell completion files are included in the release tarball for Bash, Fish, Zsh and PowerShell. .sp For \fBbash\fP, move \fBrg.bash\fP to \fB$XDG_CONFIG_HOME/bash_completion\fP or \fB/etc/bash_completion.d/\fP. .sp For \fBfish\fP, move \fBrg.fish\fP to \fB$HOME/.config/fish/completions\fP. .sp For \fBzsh\fP, move \fB_rg\fP to one of your \fB$fpath\fP directories. . . .SH CAVEATS ripgrep may abort unexpectedly when using default settings if it searches a file that is simultaneously truncated. This behavior can be avoided by passing the \fB\-\-no\-mmap\fP flag which will forcefully disable the use of memory maps in all cases. .sp ripgrep may use a large amount of memory depending on a few factors. Firstly, if ripgrep uses parallelism for search (the default), then the entire output for each individual file is buffered into memory in order to prevent interleaving matches in the output. To avoid this, you can disable parallelism with the \fB\-j1\fP flag. Secondly, ripgrep always needs to have at least a single line in memory in order to execute a search. A file with a very long line can thus cause ripgrep to use a lot of memory. Generally, this only occurs when searching binary data with the \fB\-a/\-\-text\fP flag enabled. (When the \fB\-a/\-\-text\fP flag isn't enabled, ripgrep will replace all NUL bytes with line terminators, which typically prevents exorbitant memory usage.) Thirdly, when ripgrep searches a large file using a memory map, the process will likely report its resident memory usage as the size of the file. However, this does not mean ripgrep actually needed to use that much heap memory; the operating system will generally handle this for you. . . .SH VERSION 14.1.0 . . .SH HOMEPAGE \fIhttps://github.com/BurntSushi/ripgrep\fP .sp Please report bugs and feature requests to the issue tracker. Please do your best to provide a reproducible test case for bugs. This should include the corpus being searched, the \fBrg\fP command, the actual output and the expected output. Please also include the output of running the same \fBrg\fP command but with the \fB\-\-debug\fP flag. .sp If you have questions that don't obviously fall into the "bug" or "feature request" category, then they are welcome in the Discussions section of the issue tracker: \fIhttps://github.com/BurntSushi/ripgrep/discussions\fP. . . .SH AUTHORS Andrew Gallant <\fIjamslam@gmail.com\fP>