Skip to content

Instantly share code, notes, and snippets.

@asears
Created November 2, 2024 12:50
Show Gist options
  • Save asears/4c3192fdc5ca9463b321d48cc0c91cf3 to your computer and use it in GitHub Desktop.
Save asears/4c3192fdc5ca9463b321d48cc0c91cf3 to your computer and use it in GitHub Desktop.
RipGrep (rg) Cheat Sheet
Command Description
rg pattern Search pattern in current dir recursively
rg pattern utils.py Search in a single file utils.py
rg pattern src/ Search in dir src/ recursively
rg '^We' test.txt Regex searching support (lines starting with We)
rg -F '(test)' Search literally, i.e., without using regular expression
rg -i pattern Search pattern and ignore case (case-insensitive search)
rg -S pattern Smart case search (match case of pattern)
rg pattern -g '*.py' File globbing (search in certain files), can be used multiple times
rg pattern -g '!*.py' Negative file globing (do not search in certain files)
rg pattern -g '!dir1/' Exclude dir1
rg pattern -t py Search pattern in Python file. To list the supported filetypes, use rg --type-list
rg pattern -T py Do not search pattern in Python file type
rg -l pattern Only show files containing pattern (Do not show the lines)
rg --files-without-match pattern Show files not containing pattern
rg -v pattern Inverse search (search lines not containing pattern)
rg -w pattern Search surrounded by word boundaries.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment