2021-01-06 11:54:01 -05:00
|
|
|
# rg
|
2016-11-02 21:42:23 -06:00
|
|
|
|
2021-01-06 11:54:01 -05:00
|
|
|
> Ripgrep is a recursive line-oriented CLI search tool.
|
2019-10-09 12:50:48 -03:00
|
|
|
> Aims to be a faster alternative to `grep`.
|
2019-05-23 11:56:50 +01:00
|
|
|
> More information: <https://github.com/BurntSushi/ripgrep>.
|
2016-11-02 21:42:23 -06:00
|
|
|
|
2021-05-10 11:03:12 +02:00
|
|
|
- Recursively search the current directory for a regular expression:
|
2016-11-02 21:42:23 -06:00
|
|
|
|
2021-05-10 11:03:12 +02:00
|
|
|
`rg {{regular_expression}}`
|
2016-11-02 21:42:23 -06:00
|
|
|
|
2021-05-10 11:03:12 +02:00
|
|
|
- Search for regular expressions including all .gitignored and hidden files:
|
2016-11-02 21:42:23 -06:00
|
|
|
|
2021-05-10 11:03:12 +02:00
|
|
|
`rg --no-ignore --hidden {{regular_expression}}`
|
2016-11-02 21:42:23 -06:00
|
|
|
|
2021-05-10 11:03:12 +02:00
|
|
|
- Search for a regular expression only in a certain filetype (e.g., html, css, etc.):
|
2016-11-02 21:42:23 -06:00
|
|
|
|
2021-05-10 11:03:12 +02:00
|
|
|
`rg --type {{filetype}} {{regular_expression}}`
|
2016-11-02 21:42:23 -06:00
|
|
|
|
2021-05-10 11:03:12 +02:00
|
|
|
- Search for a regular expression only in a subset of directories:
|
2016-11-02 21:42:23 -06:00
|
|
|
|
2021-05-10 11:03:12 +02:00
|
|
|
`rg {{regular_expression}} {{set_of_subdirs}}`
|
2016-11-02 21:42:23 -06:00
|
|
|
|
2021-05-10 11:03:12 +02:00
|
|
|
- Search for a regular expression in files matching a glob (e.g., `README.*`):
|
2016-11-02 21:42:23 -06:00
|
|
|
|
2021-05-10 11:03:12 +02:00
|
|
|
`rg {{regular_expression}} --glob {{glob}}`
|
2018-09-06 09:46:53 -04: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
|
|
|
|
2021-05-10 11:03:12 +02:00
|
|
|
`rg --files-with-matches {{regular_expression}}`
|
2018-12-08 19:01:13 +07:00
|
|
|
|
2021-05-10 11:03:12 +02:00
|
|
|
- Show lines that do not match the given regular expression:
|
2018-12-08 19:01:13 +07:00
|
|
|
|
2021-05-10 11:03:12 +02:00
|
|
|
`rg --invert-match {{regular_expression}}`
|
2020-04-03 14:13:24 +13:00
|
|
|
|
|
|
|
- Search a literal string pattern:
|
|
|
|
|
2021-05-19 11:19:10 -04:00
|
|
|
`rg --fixed-strings -- {{string}}`
|