Show Menu

ripgrep Cheat Sheet by

File and Path Selection

Enable binary file searching
Follow symbolic links (not default)
-g <GLOB>
Include or exclude files and direct­ories. Overrides any other ignore logic.
--iglob <GLOB>
Like -g but case-i­nse­nsitive
Don't respect any ignore files
Search in compressed files
-t <T>
-T <T>
Only search for (-t) / exclude (-T) files of TYPE. Use --typ­e-list to show all
Globbing rules match .gitignore style. Precede glob with a ! to exclude.

There are several other options to not respect only certain ignore files: ‑‑no‑ignore‑dot, ‑‑no‑ignore‑global, ‑‑no‑ignore‑parent, and ‑‑no‑ignore‑vcs.

The -z option requires decompression binaries to be on the PATH. Consider instead the ripgrep-all variant.

Matcher Selection

Treat pattern as literal string
Use the PCRE2 regex engine
Choose regex engine based on features used in pattern
Use the PCRE2 engine to support look-a­round or backre­fer­ences.

Matching Control

Search case-s­ens­itively
Search case-i­nse­nsi­tively if pattern is all lowercase, otherwise sensit­ively
Treat CRLF as line terminator for $
--pre <CMD>
Preprocess file with CMD before searching
Used to specify which files to preprocess
Used to specify multiple patterns or protect patterns starting with "­-"
Only matches surrounded by word boundaries
Count matched lines/file
Count matches per file

Other Options

Hide file open/read errs
Flush on in-memory buffer size (default in pipeline or to file)
Flush per line (default in terminal)
--encoding <ENC>
Encoding for reading files (e.g. utf-8, utf-16, ascii, windo­ws-­1252)
-j <NUM>
Approx threads to use
-[A|B|C] <num>
Show <n­um> lines after each match (A), before (B), or before and after (C)
More encodings here.

Output Options

--color <WHEN>
auto, never, always, or ansi (emit ANSI escapes).
Show column numbers (1-based) for first match
Show only names of matching files
Show only names of non-­mat­ching files
File path at start of line instead of before group
Never print file name
Suppress line numbers
-0, --null
Follow any file path with a NUL byte
Use NUL as a line terminator instead of '\n'
Print only match
Alt char for outputting path separator
-p, --pretty
Alias for ‑‑color always ‑‑heading ‑‑line­‑nu­mber
-r <TEXT>
Replace match with <T­EXT­> in output (will never modify files)
--sort <SORTBY>
Sorts results ascending (--sortr for descen­ding). Options: path, modif­ied, acces­sed, created, none
Trim lead whitespace
Quiet, no output

Help Us Go Positive!

We offset our carbon usage with Ecologi. Click the link below to help us!

We offset our carbon footprint via Ecologi


No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          More Cheat Sheets by njones

          Grep Cheat Sheet