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.
Incorrect. +7 selects files older than seven days.
find /home/shared -type f -mtime -7Correct. find /home/shared -type f -mtime -7 selects recent files.
Correct. find /home/shared -type f -mtime -7 selects recent files.
find /home/shared -type f -atime -7Incorrect. -atime tests access time, not modification time.
Incorrect. -atime tests access time, not modification time.
find /home/shared -type f -size -7Incorrect. -size tests size, not age.
Incorrect. -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 / 一時ファイル
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.