Everywhere All articles Download Buy for $19

Command line and power tools

What the shell does to your asterisk

Updated 2026-08-08 · 4 min read

The difference between rm *.log doing what you meant and doing something memorable is understanding one fact: the shell, not the command, expands the pattern — before the command ever runs.

The expansion, made visible

When you type ls *.pdf, zsh replaces *.pdf with the actual matching filenames and *then* runs ls. Seeing the expansion is one keystroke away — type the pattern and press Tab, or preview safely:

echo *.pdf

echo is the dry run for any glob: it prints exactly what the destructive command would receive.

The patterns

PatternMatches
*.pdfany .pdf in this folder
report-?.pdfone single character
*.[jp]*g.jpg, .jpeg, .png-ish sets
**/*.pdfrecursive, all subfolders

is the one worth installing into your fingers: ls /*.sketch finds every Sketch file below here, no find command required. It works in default macOS zsh; bash needs shopt -s globstar.

The three traps

Hidden files are excluded. * skips dotfiles by design — cp * /backup silently leaves .env behind. Match them deliberately with .* or zsh's *(D).

No match is an error in zsh. A pattern matching nothing aborts the command (zsh: no matches found) — safer than bash, which passes the literal *.pdf to the program as text, producing the classic confusing failure inside the command instead.

Spaces are fine, quoting is not. A *quoted* glob is literal: rm "*.log" tries to delete one file named asterisk-dot-log. Quote filenames, never patterns.

Globs or find?

Globs are for the current situation — quick, visual, interactive. The find command is for conditions globs cannot express (size, age, type) and for scripts, where its explicitness is a feature. The practical split: glob until the question involves *when* or *how big*, then reach for find.

Common questions

Why does my glob say 'no matches found'?

zsh treats a non-matching pattern as an error rather than passing it through. The pattern is wrong for this folder — echo it to see, or check hidden-file and case issues.

How do I match files in all subfolders?

The pattern: /*.pdf expands recursively in zsh. It replaces a whole class of simple find invocations.

Find any file before you finish typing

Everywhere keeps track of every file on your Mac, including the folders Spotlight hides and drives you have unplugged. Free for a day, then $19 once.

Version 2.20.3 · macOS 13+ · 4.7 MB · notarised

Related

© 2026 Caretopia Network Private Limited Everywhere for Mac Buy a licence Articles Privacy Support