rg <Pattern> [Path...]

Recursively searches current directory for lines matching a pattern

Arguments

NameDescription
PatternA regular expression used for searching
PathA file or directory to search

Options

NameDescription
-A, --after-context <Num>Shows NUM lines after each match
--auto-hybrid-regexWhen this flag is used, ripgrep will dynamically choose between supported regex engines depending on the features used in a pattern
-B, --before-context <Num>Shows NUM lines before each match
--binaryEnabling this flag will cause ripgrep to search binary files
--block-bufferedWhen enabled, ripgrep will use block buffering
-b, --byte-offsetPrints the 0-based byte offset within the input file before each line of output
-s, --case-sensitiveSearch case sensitively
--color <when>Controls when to use colors
--colors <Color Spec...>Specifies color settings for use in the output
--columnShows column numbers for the first match on each line
-C, --context <NUM>Shows NUM lines before and after each match
--context-separator <Separator>The string used to separate non-contiguous context lines in the output
-c, --countSuppresses normal output and shows the number of lines that match the given pattersns for each file searched
--count-matchesSuppresses normal output and shows the number of individual matches of the given patterns for each file searched
--crlfTreats CRLF as a line terminator instead of just a line break
--debugShows debug messages
--dfa-size-limit <NUM> [suffix]The upper size limit of the regex DFA
-E, --encoding <Encoding>Specifies the text encoding that ripgrep will use on all files searched
--engine <Engine>Specifies which regular expression engine to use
-f, --file <Patternfile...>Searches for patterns from the given file, with one pattern per line
--filesPrints each file that would be searched without actually performing the search
-l, --files-with-matchesOnly prints the paths with at least one match
--files-without-matchOnly prints the paths that contains zero matches
-F, --fixed-stringsTreats the pattern as a literal string instead of a regular expression
-L, --followFollows symbolic links while traversing directories
-g, --glob <GLOB...>Includes or excludes files and directories for searching that match the given glob
--glob-case-insensitiveProcesses glob patterns given with the -g/--glob flag
--headingPrints the file path above clusters of matches from each file instead of printing the file path as a prefix for reach matched line
--hiddenSearches hidden files and directories
--iglob <GLOB...>Includes or excludes files and directories for searching that match given the glob
--ignore-file <Path...>Specifies a path to one or more .gitignore format rules files
--ignore-file-case-insensitiveProcess ignores files case insensitively
--include-zeroPrints the number of matchesfor each file when used with --count or --count matches
-v, --invert-matchInverts matching
--jsonEnables printing results in a JSON Lines format
--no-jsonDisables the JSON Lines format
--line-bufferedEnables line buffering
-n, --line-numberShows the line numbers (1-based)
-x, --line-regexpOnly shows matches surrounded by line boundaries
-M, --max-columns <NUM>Don't print lines longer than this limit in bytes
--max-columns-previewCompletely replaces any line that is too long with a message indicating that a matching line was removed
-m, --max-count <NUM>Limits the number of matching lines per file searched to NUM
--max-depth <NUM>Limits the depth of directory traversal to NUM levels beyond the paths given
--max-filesize <NUM> [Suffix]Ignores files larger than NUM in size
-mmapSearches using memory maps when possible
-U, --multilineEnables matching across multiple lines
--multiline-dotallEnables dot all in your regex pattern
--no-configNever read configuration files
-I, --no-filenameNever prints the file path with the matched lines
--no-headingDon't group matches by each file
--no-ignoreDon't respect ignore files (.gitignore, .ignore, etc.)
--no-ignore-dotDon't respect .ignore files
--no-ignore-excludedDon't respect ignore files that are manually configured for the repository
--no-ignore-filesIgnores any --ignore-file flags
--no-ignore-globalDon't respect ignore files that come from `global` sources
--no-ignore-messagesSuppresses all error messages related to parsing ignore files
--no-ignore-parentDon't repsect ignore files in parent directories
--no-ignore-vcsDon't respect version control ignore files
-N, --no-line-numberSuppress line numbers
--no-messagesSuppresses all error messages related to opening and reading files
--no-mapNever use memory maps, even when they might be faster
--no-pcre2-unicode
--no-require-gitWill only respect global gitignore rules
--no-unicodeTurn off unicode
--unicodeDisables --no-unicode flag
-0, --nullWhenever a file path is printed, follow it with a NUL byte
--null-dataUses NUL as a line terminator instead of the default line break
--one-file-systemWill not cross file system boundaries relative to where the the search started from
--no-one-file-systemDisables `--one-file-system` flag
-o, --only-matchingPrints only the matched (non-empty) parts of a matching line, with each such part on a separate output line
--passthruPrints both matching and non-matching lines
--path-separator <Separator>Sets the path separator to use when printing file paths
-P, --pcre2Usess the PCRE2 regex engine instead of its default regex engine
--pcre2-versionPrints the version of PCRE2 in use
--pre <Command>For each input File, search the standard output of the command
--pre-glob <GLOB...>Only files that match the given set of globs will be handed to the command specified by the `--pre flag`
-p, --prettyConvenience alias for `--color always --heading --line-number`
-q, --quietDo not print anything to stdout
--regex-size-limit <NUM> [Suffix]Sets the upper size limit of the compiled regex
-e, --regexp <Pattern...>A pattern to search for
-r, --replace <Replacement Text>Replace every match with the text given when printing results
-z, --search-zipSearch in compressed files
-S, --smart-caseSearches case insensitively if the pattern is all lowercase
--sort <Sortby>
--sortr <Sortby>Enables sorting results in descending order
--statsPrints aggregate statistics about this ripgrep search
-a, --textSearches binary files as if they were text
-j, --threads <NUM>The approximate number of threads to use
--trimAll ASCII whitespace at the beginning of each line printed will be trimmed
-t, --type <Type...>Only searches files matching TYPE
--type-add <Type Spec...>Add a new glob for a particular file type
--type-clear <type...>Clear the file type globs previously defined for type
--type-listShows all supported file types and their corresponding globs
-T, --type-not <type...>Do not search files matching type
-u, --unrestrictedReduce the level of smart searching, increase by adding `u`s, ex: -uuu
--vimgrepShows results with every match on its own line, including line numbers and column nnumbers
-H, --with-filenameDisplays the file path for matches
-w, --word-regexpOnly shows the matches surrounded by word boundaries