AI disclosure: this article was created with the help of AI. An AI assistant drafted the text from the lesson script, and it was reviewed before publishing. Every command was actually run in a fresh debian:13 container (GNU findutils 4.10.0, GNU tar 1.35); all outputs below are copied from that run, not written by hand.
Find every file that changed in the last 24 hours, understand why -mtime +1 silently skips files that are almost two days old, skip folders like node_modules with -prune (and why you need -print), and back up the results safely with -print0 and tar.
The problem: Something on your server changed since yesterday, and you want to know what. The tool for that is find.
The demo folder
First, a small project to play with. I gave each file a different modification time with touch -d, from ten minutes ago up to five days ago.
$ find . -type f -printf '%TY-%Tm-%Td %TH:%TM %p\n' | sort 2026-11-16 18:19 ./LICENSE 2026-11-19 16:19 ./src/old_notes.txt 2026-11-19 19:19 ./README.md 2026-11-20 12:19 ./src/utils.py 2026-11-20 22:19 ./src/config.yaml 2026-11-21 15:19 ./logs/app.log 2026-11-21 17:19 ./node_modules/pkg/index.js 2026-11-21 18:09 ./src/app.py Here they are, oldest at the top. Keep an eye on the readme, changed forty-seven hours ago, and old notes, fifty hours ago. They will matter in a minute.
Modified in the last 24 hours: -mtime -1
The classic answer is find . -type f -mtime -1.
$ find . -type f -mtime -1 ./src/app.py ./src/config.yaml ./node_modules/pkg/index.js ./logs/app.log -mtime counts age in whole days. Minus one means: less than one day old. So we get the four files from the last twenty-four hours, including the one inside node_modules. -type f keeps only regular files. Without it, directories whose contents changed would show up too.
The trap: -mtime 1 and -mtime +1
Now the part that surprises people. What does plain one mean?
$ find . -type f -mtime 1 ./src/utils.py ./README.md Plain one means: between one and two days old. Utils, at thirty hours, and the readme, at forty-seven hours. So -mtime +1 must mean older than one day, right? Let's check.
$ find . -type f -mtime +1 ./src/old_notes.txt ./LICENSE Only old notes and the license. The readme, almost two days old, is missing. That's because find throws away the fraction of a day before comparing. Forty-seven hours becomes one whole day, and one is not greater than one. In practice, +1 means at least two full days. If you need exact numbers, stop counting in days.
Exact times with -mmin
-mmin works the same way, but in minutes. Here is everything changed in the last two hours.
$ find . -type f -mmin -120 ./src/app.py ./node_modules/pkg/index.js And -mmin -1440 is exactly twenty-four hours, with no rounding surprises. For anything older than a day, use -mmin +1440 instead of -mtime +1.
Human-readable dates with -newermt
If doing minute arithmetic isn't your thing, -newermt accepts a date in plain words.
$ find . -type f -newermt '6 hours ago' ./src/app.py ./node_modules/pkg/index.js ./logs/app.log It also takes a real calendar date. Every file here is newer than January two thousand, so we count eight.
$ find . -type f -newermt '2000-01-01' | wc -l 8 Combine it with an exclamation mark, which means not, and you get a time window. Here: changed between two days ago and one day ago.
$ find . -type f -newermt '2 days ago' ! -newermt '1 day ago' ./src/utils.py ./README.md Skipping folders with -prune
Folders like node_modules or dot git can flood the results. To skip one, use -prune.
$ find . -path ./node_modules -prune -o -type f -mmin -1440 ./src/app.py ./src/config.yaml ./node_modules ./logs/app.log Look closely: the folder itself still shows up in the list. Without an explicit action, find prints everything that matched, including the pruned path. The fix is to add -print at the end, so only the right side of the or gets printed.
$ find . -path ./node_modules -prune -o -type f -mmin -1440 -print ./src/app.py ./src/config.yaml ./logs/app.log Clean. Three files, and nothing from node_modules.
Show when each file changed
A bare list of names is not very helpful. -printf can put the modification time in front of each name, and sort puts the newest at the bottom.
$ find . -path ./node_modules -prune -o -type f -mmin -1440 -printf '%TY-%Tm-%Td %TH:%TM %p\n' | sort 2026-11-20 22:19 ./src/config.yaml 2026-11-21 15:19 ./logs/app.log 2026-11-21 18:09 ./src/app.py Now you can see the order in which things changed. That is often the real answer to the question: what happened yesterday?
Back up today's changes safely
Finally, let's do something with the results: pack them into an archive. -print0 separates names with a null byte, and tar --null -T - reads that list. Spaces or newlines in file names can't break it.
$ find . -path ./node_modules -prune -o -type f -mmin -1440 -print0 | tar --null -T - -czf /tmp/recent.tgz Let's list what went into the archive.
$ tar -tzvf /tmp/recent.tgz -rw-r--r-- root/root 5 2026-11-21 18:09 ./src/app.py -rw-r--r-- root/root 5 2026-11-20 22:19 ./src/config.yaml -rw-r--r-- root/root 5 2026-11-21 15:19 ./logs/app.log Three files, with their original times. If you just want a detailed listing instead, -exec ls -l {} + does it in one call.
$ find . -path ./node_modules -prune -o -type f -mmin -1440 -exec ls -l {} + -rw-r--r-- 1 root root 5 Nov 21 15:19 ./logs/app.log -rw-r--r-- 1 root root 5 Nov 21 18:09 ./src/app.py -rw-r--r-- 1 root root 5 Nov 20 22:19 ./src/config.yaml The trap, in one paragraph
find -mtime +1 does not mean "older than 24 hours". find drops the fraction of a day before comparing, so a file changed 47 hours ago counts as 1 day, and 1 is not greater than 1. In the demo, README.md (47 h old) is missing from -mtime +1. If you need exact numbers, count minutes: -mmin +1440.
Quick check
1. I want every file changed in the last 24 hours. Do I use -mtime 1 or -mtime -1?
-mtime -1-mtime 1-mtime +1
-mtime -1: -mtime -1 means less than one day old. Plain one means one to two days old.2. README.md is 47 hours old. Will find . -type f -mtime +1 list it?
- Yes, +1 means older than 24 hours
- No: it needs two full days; use -mmin +1440
No: it needs two full days; use -mmin +1440: Forty-seven hours rounds down to one day, and one is not greater than one.
Recap
-mtime -1 or -mmin -1440 for the last day. Remember that -mtime +1 really means two days or more. Use -newermt for dates in plain words, -prune plus -print to skip folders, and -print0 whenever you pass file names to another command.
Source and reproducible setup
- Lesson page with the same quiz (and a video version): https://shellprovenai.github.io/lekcje/find-changed-24h/
- Commands, demo setup script and full test log: https://github.com/shellprovenai/terminal-tutorials/tree/main/find-changed-24h
This article was created with the help of AI and reviewed before publishing. The video on the lesson page uses AI narration and AI-generated robot-and-dog presenters. No sponsors, no affiliate links.