Skip to content

/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

bash
touch a.txt b.txt
mkdir -p sub && touch sub/c.txt
find . -name *.txt

Output · 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

bash
touch a.txt b.txt
mkdir -p sub && touch sub/c.txt
find . -name '*.txt' | sort

Output

./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:

bash
mkdir -p logs
find -name '*.log' logs

Output · exit 1

find: paths must precede expression: `logs'
find: possible unquoted pattern after predicate `-name'?

Write find logs -name '*.log' instead.

Sources