Skip to content
Latchkey

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

Terminal
find . -path '*/dist/*.js'
find . -path '*/__tests__/*'
find . -path './src/*' -name '*.ts'

Options

PredicateWhat it does
-path PATTERNMatch the whole path against a glob (* matches /)
-wholename PATTERNGNU synonym for -path
-ipath PATTERNCase-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.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →