Skip to content

ripgrep rg Snippets

Terminal window
# Search for a regexp pattern, literal '-foo'
rg -e -foo
# Search case sensitive (default search)
rg -s John
# Search case insensitive, ignore case
rg -i
# Search for files in the current directory and all subdirectories
rg -lU --multiline-dotall 'foo.*bar|bar.*foo'
# for files containing the string "foo" and "bar"
# -l : List files that contain a match (don't print the matching lines)
# -U : multiline
# regex : when foo is before bar or reverse
# List files with case insensitive search
rg -li 'string_to_search_for'
# For word in specified files
rg -w word file1 file2 file3
#or
rg "word" *volunteer*.org
# Check pattern in specific path, files
rg -i host -g '*.env'
# Search all files including hidden files in current directory and subdirectories
rg --hidden "word"
# search for apple, banana and/or cherry in any order in
# current directory's files
rg -e --pcre2 '^(?=.*apple)(?=.*banana)(?=.*cherry).*' .