Show Menu
Cheatography

ripgrep Cheat Sheet by

File and Path Selection

--binary
Enable binary file searching
-L
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
--no-ignore
Don't respect any ignore files
-z
Search in compressed files
-t
<T>

-T
<T>
Only search for (
-t
) / exclude (
-T
) files of TYPE. Use
--type­-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

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

Matching Control

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

Other Options

--no-messages
Hide file open/read errs
--block-buffered
Flush on in-memory buffer size (default in pipeline or to file)
--line-buffered
Flush per line (default in terminal)
--encoding
<ENC>
Encoding for reading files (e.g.
utf-8
,
utf-16
,
ascii
,
window­s-1252
)
-j
<NUM>
Approx threads to use
-[A|B|C]
<num>
Show
<nu­m>
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).
--column
Show column numbers (1-based) for first match
-l
Show only names of matching files
--files-without-
match
Show only names of non-matching files
--no-heading
File path at start of line instead of before group
-I
Never print file name
-N
Suppress line numbers
-0, --null
Follow any file path with a NUL byte
--null-data
Use NUL as a line terminator instead of '\n'
-o
Print only match
--path-separator
  
<S>
Alt char for outputting path separator
-p, --pretty
Alias for
‑‑color always ‑‑heading ‑‑line­‑number
-r
<TEXT>
Replace match with
<TE­XT>
in output (will never modify files)
--sort
<SORTBY>
Sorts results ascending (
--sortr
for descen­ding). Options:
path
,
modified
,
accessed
,
created
,
none
--trim
Trim lead whitespace
-q
Quiet, no output
   
 

Comments

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