2025-03-14 21:59:59 -06:00
|
|
|
# rg
|
|
|
|
|
|
2025-04-03 20:36:56 -06:00
|
|
|
> Ripgrep, a recursive line-oriented search tool.
|
2025-03-14 21:59:59 -06:00
|
|
|
> Aims to be a faster alternative to `grep`.
|
2025-05-08 12:26:01 -06:00
|
|
|
> More information: <https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md>.
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-05-08 12:26:01 -06:00
|
|
|
- Recursively search current directory for a pattern (regular expression):
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-05-08 12:26:01 -06:00
|
|
|
`rg {{pattern}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-05-08 12:26:01 -06:00
|
|
|
- Recursively search for a pattern in a file or directory:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-05-08 12:26:01 -06:00
|
|
|
`rg {{pattern}} {{path/to/file_or_directory}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-05-08 12:26:01 -06:00
|
|
|
- Include hidden files and entries listed in `.gitignore`:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-05-08 12:26:01 -06:00
|
|
|
`rg {{[-.|--hidden]}} --no-ignore {{pattern}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-05-08 12:26:01 -06:00
|
|
|
- Only search the files whose names match the glob pattern(s) (e.g. `README.*`):
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-05-08 12:26:01 -06:00
|
|
|
`rg {{pattern}} {{[-g|--glob]}} {{filename_glob_pattern}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-05-08 12:26:01 -06:00
|
|
|
- Recursively list filenames in the current directory that match a pattern:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-05-08 12:26:01 -06:00
|
|
|
`rg --files | rg {{pattern}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Only list matched files (useful when piping to other commands):
|
|
|
|
|
|
2025-05-08 12:26:01 -06:00
|
|
|
`rg {{[-l|--files-with-matches]}} {{pattern}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-05-08 12:26:01 -06:00
|
|
|
- Show lines that do not match the pattern:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-05-08 12:26:01 -06:00
|
|
|
`rg {{[-v|--invert-match]}} {{pattern}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-05-08 12:26:01 -06:00
|
|
|
- Search for a literal string pattern:
|
2025-03-14 21:59:59 -06:00
|
|
|
|
2025-05-08 12:26:01 -06:00
|
|
|
`rg {{[-F|--fixed-strings]}} -- {{string}}`
|