/errors/find/paths-must-precede-expression
find: paths must precede expression
verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash) · find (GNU findutils) 4.11.0updated 2026-10-20
- tool
- find
- exit code
- 1
- versions
- GNU findutils 4.x
- os
- linux, windows
GNU find prints find: paths must precede expression when the shell expands an unquoted pattern like *.txt into several file names before find runs: find . -name *.txt becomes find . -name a.txt b.txt, and b.txt is not a valid expression. Quote the pattern.
Reproduce the error
touch a.txt b.txt
mkdir -p sub && touch sub/c.txt
find . -name *.txtOutput · exit 1
find: paths must precede expression: `b.txt' find: possible unquoted pattern after predicate `-name'?
With exactly one matching file in the current directory the command does not fail: it silently searches for that one name, which is an even sneakier bug.
Fix: quote the pattern
touch a.txt b.txt
mkdir -p sub && touch sub/c.txt
find . -name '*.txt' | sortOutput
./a.txt ./b.txt ./sub/c.txt
Single quotes, double quotes or a backslash (-name \*.txt) all stop the shell from expanding the glob.
Paths first, expression second
find's syntax is find [paths...] [expression]. A path after an expression triggers the same error:
mkdir -p logs
find -name '*.log' logsOutput · exit 1
find: paths must precede expression: `logs' find: possible unquoted pattern after predicate `-name'?
Write find logs -name '*.log' instead.
Sources
Related pages
errors · sedsed: -e expression #1, char N: unterminated `s' commandGNU sed reports unterminated `s' command when a substitution misses its final delimiter, often because the pattern or replacement contains an unescaped slash.cheat sheets · awkawk cheat sheet: fields, patterns, sums and printfawk cheat sheet: print fields, change the separator, filter rows by pattern or condition, sum and count columns, use BEGIN and END, printf formats and arrays.commands · tartar -xzf: extract a .tar.gz archiveExtract a .tar.gz archive with tar -xzf archive.tar.gz. Use -C to choose the target directory, -t to list contents first and -v to print each extracted file.