find -name: Match Files by Name in CI
find -name matches the last component of each path against a shell-style glob pattern.
The most common find predicate. -name tests only the base name, so quote the pattern to keep the shell from expanding it first.
What it does
find -name PATTERN matches files whose base name (the part after the last slash) matches the glob PATTERN. Wildcards * ? and [...] work, but a leading dot is matched normally, unlike in the shell. The match is case sensitive.
Common usage
find . -name '*.log'
find . -name 'package.json'
find src -name '*.test.js'Options
| Predicate | What it does |
|---|---|
| -name PATTERN | Match base name against a glob (case sensitive) |
| -iname PATTERN | Case-insensitive base-name match |
| * | Match any run of characters (but not / ) |
| ? | Match a single character |
| [abc] | Match one character from the set |
In CI
Always single-quote the pattern: find . -name *.log lets the shell expand *.log against the current directory first, so find sees already-expanded names and behaves unexpectedly. Quoting passes the literal pattern to find.
Common errors in CI
"find: paths must precede expression: 'foo.log'" almost always means an unquoted -name pattern that the shell expanded into several file names. Quote it. "find: No such file or directory" on a starting path means the directory argument is missing or wrong, not the pattern.