tldr/pages/common/rg.md

38 lines
1.1 KiB
Markdown
Raw Normal View History

# rg
2016-11-03 06:42:23 +03:00
> Ripgrep is a recursive line-oriented CLI search tool.
> Aims to be a faster alternative to `grep`.
> More information: <https://github.com/BurntSushi/ripgrep>.
2016-11-03 06:42:23 +03:00
- Recursively search the current directory for a regular expression:
2016-11-03 06:42:23 +03:00
`rg {{regular_expression}}`
2016-11-03 06:42:23 +03:00
- Search for regular expressions recursively in the current directory, including hidden files and files listed in `.gitignore`:
2016-11-03 06:42:23 +03:00
`rg --no-ignore --hidden {{regular_expression}}`
2016-11-03 06:42:23 +03:00
- Search for a regular expression only in a certain filetype (e.g. HTML, CSS, etc.):
2016-11-03 06:42:23 +03:00
`rg --type {{filetype}} {{regular_expression}}`
2016-11-03 06:42:23 +03:00
- Search for a regular expression only in a subset of directories:
2016-11-03 06:42:23 +03:00
`rg {{regular_expression}} {{set_of_subdirs}}`
2016-11-03 06:42:23 +03:00
- Search for a regular expression in files matching a glob (e.g. `README.*`):
2016-11-03 06:42:23 +03:00
`rg {{regular_expression}} --glob {{glob}}`
2018-09-06 16:46:53 +03:00
2019-11-04 12:54:16 +03:00
- Only list matched files (useful when piping to other commands):
2018-09-06 16:46:53 +03:00
`rg --files-with-matches {{regular_expression}}`
2018-12-08 15:01:13 +03:00
- Show lines that do not match the given regular expression:
2018-12-08 15:01:13 +03:00
`rg --invert-match {{regular_expression}}`
- Search a literal string pattern:
`rg --fixed-strings -- {{string}}`