find /path/to/directory -mtime -1
-mtime -1 = modified within the last 24 hours.
find /var/log -atime +7
-atime +7 = accessed older than 7 days.
find /tmp -mmin -120
-mmin -120 = modified in the last 120 minutes.
find . -newer reference.txt
Lists files modified after `reference.txt`.
find /old_files -type f -mtime +30 -delete
Deletes files older than 30 days (use with caution).
find /Documents -name "*.pdf" -atime -30 -ls
-name filters by extension, -ls shows details.
find /logs -empty -mtime +180
Finds empty files older than 180 days.
find / -mtime -1 -exec ls -l {} \;
-exec runs `ls -l` on matching files.
find /projects -type d -mtime 0
-type d searches directories only.
find /archive -mtime +3 -mtime -7
Matches files modified between 3 and 7 days ago.
find /home/user -daystart -atime 0
-daystart calculates time from midnight.
find . -cmin -60
-cmin checks file status change time.
find /backups -mtime +30 -exec mv {} /old_backups/ \;
Moves files older than 30 days to another directory.
find / -newermt "2023-10-01"
-newermt uses a date format like `YYYY-MM-DD`.
find /var/log -name "*.log" -mtime +7
Filters log files older than 7 days.
find . ! -newer reference.txt
! inverts the logic (files older than `reference.txt`).
find / -atime +30 -print
-print is the default action (useful for testing).
find / -type d -empty -mtime +365 -delete
Clean up old empty directories safely.
find /tmp -mmin -5
Finds recently modified temporary files.
find / -mmin +60 -mmin -120
Matches files modified between 1 and 2 hours ago.
find /old_files -mtime +4015
4015 days ≈ 11 years.
find /photos -name "*.jpg" -ctime -7
-ctime checks inode change time.
find / -newermt "2023-10-05 14:30"
Use time format `YYYY-MM-DD HH:MM`.
find / -mtime -1 -exec echo "File found: {}" \;
-exec with `echo` for testing.
find /projects -type d -mtime -30
Filters directories modified within the last 30 days.
| Option | Description | Example |
|---|---|---|
-mtime n |
Modified in last `n*24` hours | find . -mtime 2 |
-mmin n |
Modified in last `n` minutes | find . -mmin -30 |
-newer file |
Modified after `file` | find . -newer log.txt |
-daystart |
Calculate from start of today | find . -daystart -atime 0 |
-mtime uses days (24-hour increments).-mmin uses minutes for finer control.+ for "older than" and - for "newer than".-print to test before using -exec or -delete.