Skip to content
Latchkey

find -newer: Compare Against a Reference File

find -newer FILE matches files modified more recently than the reference FILE.

The most portable time test. Touch a marker before a step, then find -newer marker to capture everything that step wrote.

What it does

find -newer REF matches any file whose modification time is later than that of REF. Combined with touch it gives a precise, portable "changed since" gate that works the same on GNU and BSD. GNU also offers -newermt to compare against a literal date string.

Common usage

Terminal
touch /tmp/start
# ... run a build step ...
find . -type f -newer /tmp/start
find . -newermt '2026-06-01' -type f     # GNU: newer than a date

Options

ExpressionWhat it does
-newer FILEModified more recently than FILE (portable)
-newermt DATEGNU: modified after a literal date/time string
-anewer FILEAccessed more recently than FILE
-cnewer FILEInode changed more recently than FILE

In CI

The touch-a-marker-then -newer pattern is the most portable way to find "what this job just produced", since it avoids the GNU-only -mmin and -daystart. Create the marker with touch -d for a fixed cutoff when you do not control the build timing.

Common errors in CI

"find: -newermt: No such file or directory" or "unknown predicate -newermt" means BSD/macOS find, which lacks -newermt; create a reference file with touch -d DATE and use -newer instead. "find: I cannot figure out how to interpret ... as a date" comes from an unparseable -newermt string.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →