HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

rg — Ripgrep, a recursive line-oriented search tool. Aims to be a faster alternative to `grep`. More info

Submitted by: @import:tldr-pages··
0
Viewed 0 times
commandripgrepsearchclirecursiveorientedlinerg

Problem

How to use the rg command: Ripgrep, a recursive line-oriented search tool. Aims to be a faster alternative to grep. More information: <https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md>.

Solution

rg — Ripgrep, a recursive line-oriented search tool. Aims to be a faster alternative to grep. More information: <https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md>.

Recursively search current directory for a pattern (regex):
rg {{pattern}}


Recursively search for a pattern in a file or directory:
rg {{pattern}} {{path/to/file_or_directory}}


Search for a literal string pattern:
rg {{[-F|--fixed-strings]}} -- {{string}}


Include hidden files and entries listed in .gitignore:
rg {{[-.|--hidden]}} --no-ignore {{pattern}}


Only search the files whose names match the glob pattern(s) (e.g. README.*):
rg {{pattern}} {{[-g|--glob]}} {{filename_glob_pattern}}


Recursively list filenames in the current directory that match a pattern:
rg --files | rg {{pattern}}


Only list matched files (useful when piping to other commands):
rg {{[-l|--files-with-matches]}} {{pattern}}


Show lines that do not match the pattern:
rg {{[-v|--invert-match]}} {{pattern}}

Code Snippets

Recursively search current directory for a pattern (`regex`)

rg {{pattern}}

Recursively search for a pattern in a file or directory

rg {{pattern}} {{path/to/file_or_directory}}

Search for a literal string pattern

rg {{[-F|--fixed-strings]}} -- {{string}}

Include hidden files and entries listed in `.gitignore`

rg {{[-.|--hidden]}} --no-ignore {{pattern}}

Only search the files whose names match the glob pattern(s) (e.g. `README.*`)

rg {{pattern}} {{[-g|--glob]}} {{filename_glob_pattern}}

Context

tldr-pages: common/rg

Revisions (0)

No revisions yet.