Regex | Recursive search | Automatic filtering | Globbing | Using Type Lists | File encoding | Common options
rg -.iF 'fn write(' ripgrep-0.7.1
rg -.iza
rg -ciF 'fn write(' ripgrep-0.7.1
curl -LO https://github.com/BurntSushi/ripgrep/archive/0.7.1.zip
unzip 0.7.1.zip
cd ripgrep-0.7.1
ls
rg fast README.MD
rg 'fast\w+' README.md
rg 'fast\w*' README.md
# Find all fn definitions named write
rg 'fn write\('
rg -F 'fn write('
--no-ignore Don’t ignore .gitignore and other
ignore-related filtering.
--hidden | -. Don’t ignore hidden files.
--text | -a Search binary files.
--follow | -L Follow symbolic links.
--unrestricted | -u Ignore less: -u
will disable .gitignore handling, -uu will search
hidden files and directories and -uuu will search
binary files.
.ignore Files contents override .gitignore with
!log/ syntax to offset .gitignore rules.
-g, --glob <GLOB>... Include or exclude
files.
rg clap -g '*.toml' Single quotes to prevent our
shell from expanding the *.
rg clap -g '!*.toml' Won’t include files ending with
.toml.
rg --type-list Show all supported file
types.
rg clap -g '*.txt' Use glob syntax.
rg clap -t txt Or type list name.
rg 'fn run' --type rust Ripgrep supports certain
file types.
rg 'fn run' -trust Or shortcut for Rust file
type.
rg 'int main' -g '*.{c,h}' So, this is a
glob.
rg 'int main' -tc And this is a file type list, but
also the same thing.
rg clap --type-not rust You can blacklist with file
types.
rg clap -Trust Or simply capitalize the ‘T’ and you
exclude files of this type.
rg --type-add 'web:*.html' --type-add 'web:*.css' --type-add 'web:*.js' -tweb title
rg --type-add 'web:*.{html,css,js}' -tweb title
alias rg="rg --type-add 'web:*.{html,css,js}'"
--type-add=web:*.{html,css,js}
The most popular encodings likely consist of ASCII, latin1 or UTF-8. As a special exception, UTF-16 is prevalent in Windows environments
`--encoding auto Ripgrep’s default
behavior.
To handle the UTF-16 case, ripgrep will perform “BOM sniffing” by default. That is, the first three bytes of a file will be read, and if they correspond to a UTF-16 BOM, then ripgrep will transcode the contents of the file from UTF-16 to UTF-8, and then execute the search on the transcoded version of the file.
-E/--encoding Permits you to specify an
encoding
Will not search PDFs without preprocessing.
-h: Show ripgrep’s condensed help output.--help: Show ripgrep’s longer form help output. (Nearly
what you’d find in ripgrep’s man page, so pipe it into a pager!)-i/--ignore-case: When searching for a pattern, ignore
case differences. That is rg -i fast matches
fast, fASt, FAST, etc.-S/--smart-case: This is similar to
--ignore-case, but disables itself if the pattern contains
any uppercase letters. Usually this flag is put into alias or a config
file.-F/--fixed-strings: Disable regular expression matching
and treat the pattern as a literal string.-w/--word-regexp: Require that all matches of the
pattern be surrounded by word boundaries. That is, given
pattern, the --word-regexp flag will cause
ripgrep to behave as if pattern were actually
\b(?:pattern)\b.-c/--count: Report a count of total matched lines.--files: Print the files that ripgrep would
search, but don’t actually search them.-a/--text: Search binary files as if they were plain
text.-U/--multiline: Permit matches to span multiple
lines.-z/--search-zip: Search compressed files (gzip, bzip2,
lzma, xz, lz4, brotli, zstd). This is disabled by default.-C/--context: Show the lines surrounding a match.--sort path: Force ripgrep to sort its output by file
name. (This disables parallelism, so it might be slower.)-L/--follow: Follow symbolic links while recursively
searching.-M/--max-columns: Limit the length of lines printed by
ripgrep.--debug: Shows ripgrep’s debug output. This is useful
for understanding why a particular file might be ignored from search, or
what kinds of configuration ripgrep is loading from the
environment.