Search a tree of files
Search a tree of files
Search every file under a directory, keep or drop files by name, and list the files that match.
The walk applies .gitignore and .ignore rules and skips hidden and binary files, as
files and trees describes.
$ cat notes/c.txt
mail bob@x.com about the rollout
$ cat notes/d.txt
rollout notes for the second wave
check the queue before starting
$ cat notes/plan.md
the rollout starts monday
Search a directory
Each match is prefixed with its file, line and column:
$ trex scan '"queue" | "rollout"' notes/
notes/c.txt:1:26: "rollout"
notes/d.txt:1:1: "rollout"
notes/d.txt:2:11: "queue"
notes/plan.md:1:5: "rollout"
Keep some files and list the matches
-g GLOB keeps the files a glob names, !GLOB drops them, and -t TYPE keeps a file type
under ripgrep’s names; -l lists each file with a match once:
$ trex scan '"queue" | "rollout"' notes/ -g '*.txt' -l
notes/c.txt
notes/d.txt
The Rust tab above walks with WalkOptions { globs, .. } the same way. --hidden,
--no-ignore and --binary widen the walk, and a file named outright is read whatever the
rules say.