Find regular files under /home/shared modified less than seven days ago.
Use GNU find's day-based test.
Which condition is appropriate?
-mtime -7 selects files whose content modification age is less than seven 24-hour periods. +7 selects older files.
Detailed explanation
find /home/shared -type f -mtime +7Incorrect. +7 selects files older than seven days.
find /home/shared -type f -mtime -7Correct. find /home/shared -type f -mtime -7 selects recent files.
find /home/shared -type f -atime -7Incorrect. -atime tests access time, not modification time.
find /home/shared -type f -size -7Incorrect. -size tests size, not age.
Try it yourself
An example you can run in a temporary verification environment.
tmp=$(mktemp -d); touch "$tmp/recent"; touch -d '10 days ago' "$tmp/old"; find "$tmp" -type f -mtime -7 -printf '%f\n'; rm -rf "$tmp"Expected result
recentKey points
- -mtime tests modification time
- -7 means less than seven
- +7 means older than seven
Notes
- Environment: GNU findutils 4.x / GNU touch / 一時ファイル
- Use disposable files and directories for destructive or timestamp-related checks.
- Command details can vary slightly between GNU and non-GNU implementations.
Foundation review
Place the operation
Modification age and access age are different signals; the sign controls which side of the day threshold is selected.
Check the side effect
Remember that day tests use whole 24-hour periods; use a minute test for finer boundaries.