2021-01-06 11:54:01 -05:00
|
|
|
# rg
|
2016-11-02 21:42:23 -06:00
|
|
|
|
2025-03-17 12:21:54 +02:00
|
|
|
> Ripgrep, a recursive line-oriented search tool.
|
2019-10-09 12:50:48 -03:00
|
|
|
> Aims to be a faster alternative to `grep`.
|
2025-05-02 22:33:02 -05:00
|
|
|
> More information: <https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md>.
|
2016-11-02 21:42:23 -06:00
|
|
|
|
2025-05-02 22:33:02 -05:00
|
|
|
- Recursively search current directory for a pattern (regular expression):
|
2016-11-02 21:42:23 -06:00
|
|
|
|
2025-05-02 22:33:02 -05:00
|
|
|
`rg {{pattern}}`
|
2016-11-02 21:42:23 -06:00
|
|
|
|
2025-05-02 22:33:02 -05:00
|
|
|
- Recursively search for a pattern in a file or directory:
|
2016-11-02 21:42:23 -06:00
|
|
|
|
2025-05-03 17:44:39 +02:00
|
|
|
`rg {{pattern}} {{path/to/file_or_directory}}`
|
2016-11-02 21:42:23 -06:00
|
|
|
|
2025-05-02 22:33:02 -05:00
|
|
|
- Include hidden files and entries listed in `.gitignore`:
|
2016-11-02 21:42:23 -06:00
|
|
|
|
2025-05-02 22:33:02 -05:00
|
|
|
`rg {{[-.|--hidden]}} --no-ignore {{pattern}}`
|
2016-11-02 21:42:23 -06:00
|
|
|
|
2025-05-02 22:33:02 -05:00
|
|
|
- Only search the files whose names match the glob pattern(s) (e.g. `README.*`):
|
2016-11-02 21:42:23 -06:00
|
|
|
|
2025-05-02 22:33:02 -05:00
|
|
|
`rg {{pattern}} {{[-g|--glob]}} {{filename_glob_pattern}}`
|
2018-09-06 09:46:53 -04:00
|
|
|
|
2025-05-02 22:33:02 -05:00
|
|
|
- Recursively list filenames in the current directory that match a pattern:
|
2023-02-20 22:53:19 -08:00
|
|
|
|
2025-05-02 22:33:02 -05:00
|
|
|
`rg --files | rg {{pattern}}`
|
2023-02-20 22:53:19 -08:00
|
|
|
|
2019-11-04 10:54:16 +01:00
|
|
|
- Only list matched files (useful when piping to other commands):
|
2018-09-06 09:46:53 -04:00
|
|
|
|
2025-05-02 22:33:02 -05:00
|
|
|
`rg {{[-l|--files-with-matches]}} {{pattern}}`
|
2018-12-08 19:01:13 +07:00
|
|
|
|
2025-05-02 22:33:02 -05:00
|
|
|
- Show lines that do not match the pattern:
|
2018-12-08 19:01:13 +07:00
|
|
|
|
2025-05-02 22:33:02 -05:00
|
|
|
`rg {{[-v|--invert-match]}} {{pattern}}`
|
2020-04-03 14:13:24 +13:00
|
|
|
|
2025-05-02 22:33:02 -05:00
|
|
|
- Search for a literal string pattern:
|
2020-04-03 14:13:24 +13:00
|
|
|
|
2025-05-02 22:33:02 -05:00
|
|
|
`rg {{[-F|--fixed-strings]}} -- {{string}}`
|