Search & Regex
Fast search keeps Rust codebases navigable. ripgrep (rg) honors .gitignore, fd finds paths, and sed/awk wrangle build logs and CSV exports.
Busca en todas las páginas de la documentación
Fast search keeps Rust codebases navigable. ripgrep (rg) honors .gitignore, fd finds paths, and sed/awk wrangle build logs and CSV exports.
rg "AppError" src/
rg -t rust "unwrap\(" --glob '!tests/**'
fd '\.rs$' src/
rg -l "sqlx::query" | xargs wc -lWhen to reach for this:
unwrap or unsafe in production paths# Find enum variants and impl blocks
rg "enum AppError" -A 20 src/
# Files importing axum but not in router module
rg -l "use axum" src/ | rg -v routes
# Count lines per module
fd . src -e rs | xargs wc -l | sort -n
# Transform CI log excerpt
sed -n '/error\[E/,+3p' ci.logWhat this demonstrates:
-t rust filters file types--glob excludes test treesrg, fd, and wc| Flag | Use |
|---|---|
-F | Fixed string (no regex) |
-w | Whole word |
-C 3 | Context lines |
--stats | Match counts and timing |
-z | Search in .tar etc. |
CLI search is scriptable in CI (e.g. fail if todo!() in src/ outside tests).
grep -r includes target/ - slow and noisy. Fix: use rg or --exclude-dir=target.. matches any char. Fix: rg -F for literal strings.-i when appropriate.rg skips binaries by default.perl -pi.| Alternative | Use When | Don't Use When |
|---|---|---|
git grep | Only tracked files | Need ignore-aware speed |
ast-grep | Structural Rust search | Simple text lookup |
| rust-analyzer symbol search | Type-aware nav | CI scripting |
rg is faster and more maintained; default for Rust teams.
Run from workspace root; rg searches all crates unless scoped with -g.
Stack versions: This page was written for Rust 1.97.0 (edition 2024), Tokio 1.x, Axum 0.8, serde 1.0, sqlx 0.8, clap 4, and Polars 0.46+.
Revisado por Chris St. John·Última actualización: 16 jul 2026