Everywhere All articles Download

Command line and power tools

Regex for finding files

Updated 2026-07-31 · 4 min read

Most searches do not need regex. The ones that do usually cannot be done any other way.

Glob first

Shell globs cover most cases and are far easier to read:

find ~ -name "report-202[456]-*.pdf"

* is any run of characters, ? is one, [456] is a character class. If a glob will do, use it.

find with regex

find ~ -regex ".*/IMG_[0-9]{4}\.(jpg|heic)"

macOS ships BSD find, which uses basic regular expressions by default and has no -regextype flag. -E switches to extended syntax:

find -E ~ -regex ".*/IMG_[0-9]{4}\.(jpg|heic)"

Note that -regex matches the whole path, not just the filename — the leading .*/ is usually required and is the most common reason a pattern silently matches nothing.

grep for contents

grep -rE "invoice-[0-9]{6}" ~/Documents

-r recurses, -E gives extended regex, -l lists only filenames, -i ignores case.

Patterns worth keeping

GoalPattern
Four-digit year20[0-9]{2}
Camera files`(IMG\DSC\DSCF)_?[0-9]+`
Versioned names-v[0-9]+
Dated screenshotsScreenshot [0-9-]{10}
Anything but^(?!.*cache).*$ (needs PCRE, so grep -P or rg)

In a search box

A tool that accepts /pattern/ inline lets you use regex for the one search that needs it without leaving the interface. That is the right trade-off: plain typing for the ninety-nine cases, regex available for the hundredth.

Common questions

Why does find -regex match nothing?

It matches the entire path. Prefix your pattern with .*/ or use -name with a glob instead.

Does macOS grep support Perl regex?

BSD grep has no -P. Install ripgrep or GNU grep via Homebrew if you need it.

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.

Download for Mac

Related

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