find -path: Match the Whole Path
find -path matches a glob against the full path of each file, including slashes.
When the directory structure matters, not just the file name, -path lets you match patterns like */dist/*.js across nested folders.
What it does
find -path PATTERN matches the whole path from the starting point against the glob. Unlike -name, the * wildcard in -path does match slashes, so */test/* spans directory levels. -wholename is a GNU synonym for -path.
Common usage
find . -path '*/dist/*.js'
find . -path '*/__tests__/*'
find . -path './src/*' -name '*.ts'Options
| Predicate | What it does |
|---|---|
| -path PATTERN | Match the whole path against a glob (* matches /) |
| -wholename PATTERN | GNU synonym for -path |
| -ipath PATTERN | Case-insensitive whole-path match |
In CI
The pattern must account for the starting path. If you run find . the paths begin with ./, so -path src/* matches nothing while -path ./src/* or */src/* matches. Prefer the */src/* form so the rule does not depend on the starting argument.
Common errors in CI
A -path pattern that "matches nothing" usually forgot the leading ./ or */ that the actual paths carry. -wholename is GNU only; on BSD/macOS find use -path, which both support. Combine -path with -prune to skip whole subtrees.