---
tags:
- cli
- l1
- flashcard-deck
- ripgrep
---
<!-- wiki:breadcrumb:start -->
[Portal](../../../../library/portal/index.md) | **Level:** [L1: Foundations](../../../../library/portal/levels.md) | **Topics:** [ripgrep (rg)](../../../../library/portal/topics.md) | **Domain:** CLI Tools
<!-- wiki:breadcrumb:end -->

id	category	difficulty	tags	question	answer	source_path
ripgrep/a1d2e3f4b5c6	ripgrep	easy	ripgrep, basics, search	How does rg differ from grep in terms of recursion?	rg searches recursively by default without needing a -r flag. It also automatically skips binary files and respects .gitignore rules.\n\nRemember: "rg = ripgrep = recursive grep, fast." It respects .gitignore by default and uses Rust regex engine.\n\nFun fact: ripgrep is often 2-10x faster than grep -r due to parallelism and gitignore-aware file skipping.	training/library/topics/ripgrep/primer.md
ripgrep/b2e3f4a5c6d7	ripgrep	easy	ripgrep, output, files	How do you list only the filenames that contain a match with rg?	Use the -l flag: rg -l "pattern". This prints file paths with matches but not the matching content.\n\nExample: rg -i error matches "error", "Error", "ERROR". Add -w for whole-word matching: rg -iw error.\n\nRemember: "-i = ignore case, -w = whole word, -l = files only."	training/library/topics/ripgrep/primer.md
ripgrep/c3f4a5b6d7e8	ripgrep	easy	ripgrep, case, search	What does rg's -S (smart case) flag do?	Smart case makes the search case-insensitive unless the pattern contains an uppercase letter, in which case it becomes case-sensitive.\n\nExample: rg -t py "import os" searches only Python files. rg -T js skips JavaScript files.\n\nRemember: "-t = type include, -T = type exclude." Use rg --type-list to see all types.	training/library/topics/ripgrep/primer.md
ripgrep/d4a5b6c7e8f9	ripgrep	medium	ripgrep, types, filter	How do you restrict rg to search only specific file types?	Use the -t flag with a type name: rg -t py "import". Use rg --type-list to see all built-in types. Use -T to exclude a type.\n\nExample: rg -C 3 "panic" shows 3 lines before and after each match. -B for before only, -A for after only.\n\nRemember: "-C = Context (both), -B = Before, -A = After."	training/library/topics/ripgrep/primer.md
ripgrep/e5b6c7d8f9a0	ripgrep	medium	ripgrep, glob, filter	How do you use glob patterns to filter files in rg?	Use the -g flag: rg -g '*.conf' "listen" searches only .conf files. Use ! for exclusion: rg -g '!tests/' "func" excludes the tests directory.\n\nRemember: "rg skips .gitignore'd files and hidden dirs by default." Use --no-ignore to search everything, --hidden to include dotfiles.\n\nGotcha: If rg misses results, check if the file is gitignored or binary.	training/library/topics/ripgrep/primer.md
ripgrep/f6c7d8e9a0b1	ripgrep	medium	ripgrep, hidden, ignore	What do the stacking -u flags do in rg?	-u includes .gitignore'd files, -uu also includes hidden (dot) files, -uuu also includes binary files. Each -u removes one layer of filtering.\n\nExample: rg --glob "*.log" "timeout" searches only .log files. rg --glob "!*.min.js" skips minified JS.\n\nRemember: "--glob = file pattern filter. ! prefix = exclude."	training/library/topics/ripgrep/primer.md
ripgrep/a7d8e9f0b1c2	ripgrep	medium	ripgrep, replace	Can rg perform text replacements in files?	rg can preview replacements with --replace (rg "old" --replace "new") but does not modify files. Pipe rg -l through xargs sed for actual replacement.\n\nExample: rg -r '$1_NEW' '(\w+)_old' --passthru replaces old suffix with _NEW in output. For actual file modification, pipe to sed or use sd.\n\nRemember: "rg -r = replace in OUTPUT, not in files."	training/library/topics/ripgrep/primer.md
ripgrep/b8e9f0a1c2d3	ripgrep	hard	ripgrep, config	How do you configure default rg options via a config file?	Set RIPGREP_CONFIG_PATH to point to a config file (e.g., ~/.ripgreprc). Each line is one flag, such as --smart-case or --glob=!.git/. Options apply to every rg invocation.\n\nRemember: "-l = list files with matches, -c = count matches per file." Useful for piping: rg -l TODO | xargs wc -l.\n\nExample: rg -c "FIXME" shows how many FIXMEs per file.	training/library/topics/ripgrep/primer.md
ripgrep/c9f0a1b2d3e4	ripgrep	hard	ripgrep, regex, pcre2	When would you use rg's -P flag, and what does it enable?	-P enables PCRE2 regex, which supports lookaheads, lookbehinds, and backreferences not available in the default Rust regex engine. Use it for advanced patterns at the cost of some speed.\n\nExample: rg -g "*.py" -g "!test_*" "def " — search Python files but skip test files. Multiple -g flags combine.\n\nGotcha: Glob patterns are relative to the search directory, not the current directory.	training/library/topics/ripgrep/primer.md
ripgrep/d0a1b2c3e4f5	ripgrep	hard	ripgrep, performance	Why is rg significantly faster than grep on large repositories?	rg uses multi-threaded directory traversal, respects .gitignore to skip irrelevant files, uses an optimized regex engine (Rust), and skips binary files by default — avoiding wasted work that grep performs.	training/library/topics/ripgrep/primer.md
ripgrep/e1b2c3d4f5a6	ripgrep	easy	ripgrep, context, output	How do you show context lines around matches with rg?	Use -A N (after), -B N (before), or -C N (both): rg -C 3 "panic" shows 3 lines before and after each match. Context lines are prefixed with - instead of : to distinguish them from match lines.	
ripgrep/f2c3d4e5a6b7	ripgrep	medium	ripgrep, count, statistics	What is the difference between --count and --count-matches in rg?	--count (-c) prints the number of matching lines per file. --count-matches prints the number of individual matches per file (a line with two matches counts as 2 with --count-matches but 1 with --count).\n\nRemember: "rg -z searches compressed files." Supports gzip, bzip2, xz, lz4, and zstd.\n\nExample: rg -z "ERROR" /var/log/*.gz searches rotated log files without decompressing.	
ripgrep/a3d4e5f6b7c8	ripgrep	medium	ripgrep, limit, search	What does --max-count do in rg, and when would you use it?	--max-count N (-m N) stops searching a file after N matches. Useful for quickly confirming presence without reading entire large files: rg -m 1 "TODO" returns at most one match per file.	
ripgrep/b4e5f6a7c8d9	ripgrep	medium	ripgrep, stats, summary	What information does rg --stats provide after a search?	--stats appends a summary showing: total matches, total lines matched, total files matched, total files searched, total bytes searched, and elapsed time. Useful for understanding search scope and performance.\n\nExample: echo "hello world" | rg "\w+" -o outputs each word on its own line. Useful for extracting patterns from piped input.\n\nRemember: "-o = only matching part, not the full line."	
ripgrep/c5f6a7b8d9e0	ripgrep	easy	ripgrep, heading, output	What is the difference between --heading and --no-heading in rg?	--heading (default for terminal) groups matches by filename with the filename printed once above its matches. --no-heading prefixes every line with the filename (default for pipes). Use --no-heading for consistent machine-parseable output.	

<!-- wiki:related:start -->
---

## Wiki Navigation

### Related Content

- [Modern CLI Drills](../../../../library/drills/modern_cli_drills.md) (Drill, L0) — ripgrep (rg)
- [Modern CLI Tools](../../../../library/topics/modern-cli/index.md) (Topic Pack, L0) — ripgrep (rg)
- [Skillcheck: Modern CLI Tools](../../../../library/skillchecks/modern-cli-tools.skillcheck.md) (Assessment, L0) — ripgrep (rg)
- [ripgrep](../../../../library/topics/ripgrep/index.md) (Topic Pack, L1) — ripgrep (rg)

<!-- wiki:related:end -->
